From d1cb4e9e97b7f9fc90acdac5ee742de1610c2019 Mon Sep 17 00:00:00 2001 From: Glenn Renfro Date: Fri, 18 Oct 2024 08:01:20 -0400 Subject: [PATCH] Apply Locale.ROOT for string case change methods' locale --- .../cloud/task/repository/dao/JdbcTaskExecutionDao.java | 3 ++- .../database/support/AbstractSqlPagingQueryProvider.java | 3 ++- .../database/support/SqlPagingQueryProviderFactoryBean.java | 3 ++- .../task/repository/support/TaskRepositoryInitializer.java | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java index 5594b3ea6..0aa3e1865 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -527,7 +528,7 @@ private Page queryForPageableResults(Pageable pageable, String se if (sort != null) { for (Sort.Order sortOrder : sort) { - if (validSortColumns.contains(sortOrder.getProperty().toUpperCase())) { + if (validSortColumns.contains(sortOrder.getProperty().toUpperCase(Locale.ROOT))) { sortOrderMap.put(sortOrder.getProperty(), sortOrder.isAscending() ? Order.ASCENDING : Order.DESCENDING); } diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/AbstractSqlPagingQueryProvider.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/AbstractSqlPagingQueryProvider.java index 2daa6c60f..631a47e6f 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/AbstractSqlPagingQueryProvider.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/AbstractSqlPagingQueryProvider.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.sql.DataSource; @@ -157,7 +158,7 @@ public void init(DataSource dataSource) throws Exception { private String removeKeyWord(String keyWord, String clause) { String temp = clause.trim(); String keyWordString = keyWord + " "; - if (temp.toLowerCase().startsWith(keyWordString) && temp.length() > keyWordString.length()) { + if (temp.toLowerCase(Locale.ROOT).startsWith(keyWordString) && temp.length() > keyWordString.length()) { return temp.substring(keyWordString.length()); } else { diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/SqlPagingQueryProviderFactoryBean.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/SqlPagingQueryProviderFactoryBean.java index b9ce01eac..ad1daab7d 100755 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/SqlPagingQueryProviderFactoryBean.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/SqlPagingQueryProviderFactoryBean.java @@ -17,6 +17,7 @@ package org.springframework.cloud.task.repository.database.support; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.sql.DataSource; @@ -135,7 +136,7 @@ public PagingQueryProvider getObject() throws Exception { DatabaseType type; try { - type = this.databaseType != null ? DatabaseType.valueOf(this.databaseType.toUpperCase()) + type = this.databaseType != null ? DatabaseType.valueOf(this.databaseType.toUpperCase(Locale.ROOT)) : DatabaseType.fromMetaData(this.dataSource); } catch (MetaDataAccessException e) { diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskRepositoryInitializer.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskRepositoryInitializer.java index 82071ab4f..c09a51616 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskRepositoryInitializer.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskRepositoryInitializer.java @@ -17,6 +17,7 @@ package org.springframework.cloud.task.repository.support; import java.sql.SQLException; +import java.util.Locale; import javax.sql.DataSource; @@ -84,7 +85,8 @@ public void setResourceLoader(ResourceLoader resourceLoader) { private String getDatabaseType(DataSource dataSource) { try { - return JdbcUtils.commonDatabaseName(DatabaseType.fromMetaData(dataSource).toString()).toLowerCase(); + return JdbcUtils.commonDatabaseName(DatabaseType.fromMetaData(dataSource).toString()) + .toLowerCase(Locale.ROOT); } catch (MetaDataAccessException ex) { throw new IllegalStateException("Unable to detect database type", ex);