diff --git a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java index 519ead579879..db63f28a10c3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.Locale; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -77,8 +78,8 @@ public int compare(T o1, T o2) { Object v1 = getPropertyValue(o1); Object v2 = getPropertyValue(o2); if (this.sortDefinition.isIgnoreCase() && (v1 instanceof String) && (v2 instanceof String)) { - v1 = ((String) v1).toLowerCase(); - v2 = ((String) v2).toLowerCase(); + v1 = ((String) v1).toLowerCase(Locale.ROOT); + v2 = ((String) v2).toLowerCase(Locale.ROOT); } int result; diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java index f6042bee9347..dfa41f633cfe 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java @@ -19,6 +19,7 @@ import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; +import java.util.Locale; import javax.sql.DataSource; @@ -155,7 +156,7 @@ public void initialize() { String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, DatabaseMetaData::getDatabaseProductName); productName = JdbcUtils.commonDatabaseName(productName); - if (productName != null && productName.toLowerCase().contains("hsql")) { + if (productName != null && productName.toLowerCase(Locale.ROOT).contains("hsql")) { setUseDBLocks(false); setLockHandler(new SimpleSemaphore()); } diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/MonthFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/MonthFormatter.java index abae18df61cb..a6c56fbe9354 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/MonthFormatter.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/MonthFormatter.java @@ -34,7 +34,7 @@ class MonthFormatter implements Formatter { @Override public Month parse(String text, Locale locale) throws ParseException { - return Month.valueOf(text.toUpperCase()); + return Month.valueOf(text.toUpperCase(Locale.ROOT)); } @Override diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/CronField.java b/spring-context/src/main/java/org/springframework/scheduling/support/CronField.java index 3124cc25b5e5..e1702c9a548b 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/CronField.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/CronField.java @@ -21,6 +21,7 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.ValueRange; +import java.util.Locale; import java.util.function.BiFunction; import org.springframework.lang.Nullable; @@ -143,7 +144,7 @@ private static CronField parseList(String value, Type type, BiFunction param Assert.hasLength(subtype, "'subtype' must not be empty"); checkToken(type); checkToken(subtype); - this.type = type.toLowerCase(Locale.ENGLISH); - this.subtype = subtype.toLowerCase(Locale.ENGLISH); + this.type = type.toLowerCase(Locale.ROOT); + this.subtype = subtype.toLowerCase(Locale.ROOT); if (!CollectionUtils.isEmpty(parameters)) { - Map map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH); + Map map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT); parameters.forEach((parameter, value) -> { checkParameters(parameter, value); map.put(parameter, value); diff --git a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java index 2caaf33597f7..1538c1ced5e5 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java @@ -23,6 +23,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; +import java.util.Locale; import org.springframework.lang.Nullable; @@ -295,7 +296,7 @@ public static boolean isJarURL(URL url) { */ public static boolean isJarFileURL(URL url) { return (URL_PROTOCOL_FILE.equals(url.getProtocol()) && - url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION)); + url.getPath().toLowerCase(Locale.ROOT).endsWith(JAR_FILE_EXTENSION)); } /** diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/SpelParserConfiguration.java b/spring-expression/src/main/java/org/springframework/expression/spel/SpelParserConfiguration.java index ae94b4c3b4fa..eec9e472f173 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/SpelParserConfiguration.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/SpelParserConfiguration.java @@ -16,6 +16,8 @@ package org.springframework.expression.spel; +import java.util.Locale; + import org.springframework.core.SpringProperties; import org.springframework.lang.Nullable; @@ -45,7 +47,7 @@ public class SpelParserConfiguration { static { String compilerMode = SpringProperties.getProperty(SPRING_EXPRESSION_COMPILER_MODE_PROPERTY_NAME); defaultCompilerMode = (compilerMode != null ? - SpelCompilerMode.valueOf(compilerMode.toUpperCase()) : SpelCompilerMode.OFF); + SpelCompilerMode.valueOf(compilerMode.toUpperCase(Locale.ROOT)) : SpelCompilerMode.OFF); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java index 02e8a28c3028..8d07765888e5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java @@ -17,6 +17,7 @@ package org.springframework.expression.spel.ast; import java.lang.reflect.Array; +import java.util.Locale; import org.springframework.asm.MethodVisitor; import org.springframework.asm.Type; @@ -57,7 +58,7 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep String typeName = (String) this.children[0].getValueInternal(state).getValue(); Assert.state(typeName != null, "No type name"); if (!typeName.contains(".") && Character.isLowerCase(typeName.charAt(0))) { - TypeCode tc = TypeCode.valueOf(typeName.toUpperCase()); + TypeCode tc = TypeCode.valueOf(typeName.toUpperCase(Locale.ROOT)); if (tc != TypeCode.OBJECT) { // It is a primitive type Class clazz = makeArrayIfNecessary(tc.getType()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java index cf135d08ed23..3b4f2b8decd5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.Deque; import java.util.List; +import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.regex.Pattern; @@ -750,7 +751,7 @@ private SpelNodeImpl eatPossiblyQualifiedId() { throw internalException( this.expressionString.length(), SpelMessage.OOD); } throw internalException(node.startPos, SpelMessage.NOT_EXPECTED_TOKEN, - "qualified ID", node.getKind().toString().toLowerCase()); + "qualified ID", node.getKind().toString().toLowerCase(Locale.ROOT)); } return new QualifiedIdentifier(qualifiedIdPieces.getFirst().getStartPosition(), qualifiedIdPieces.getLast().getEndPosition(), qualifiedIdPieces.toArray(new SpelNodeImpl[0])); @@ -942,7 +943,7 @@ private Token eatToken(TokenKind expectedKind) { } if (t.kind != expectedKind) { throw internalException(t.startPos, SpelMessage.NOT_EXPECTED_TOKEN, - expectedKind.toString().toLowerCase(), t.getKind().toString().toLowerCase()); + expectedKind.toString().toLowerCase(Locale.ROOT), t.getKind().toString().toLowerCase(Locale.ROOT)); } return t; } @@ -1038,7 +1039,7 @@ public String toString(@Nullable Token t) { if (t.getKind().hasPayload()) { return t.stringValue(); } - return t.kind.toString().toLowerCase(); + return t.kind.toString().toLowerCase(Locale.ROOT); } private void checkOperands(Token token, @Nullable SpelNodeImpl left, @Nullable SpelNodeImpl right) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java index 5034c960ec61..f85dacf6a6b3 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; import org.springframework.expression.spel.InternalParseException; import org.springframework.expression.spel.SpelMessage; @@ -455,7 +456,7 @@ private void lexIdentifier() { // Check if this is the alternative (textual) representation of an operator (see // alternativeOperatorNames) if ((this.pos - start) == 2 || (this.pos - start) == 3) { - String asString = new String(subarray).toUpperCase(); + String asString = new String(subarray).toUpperCase(Locale.ROOT); int idx = Arrays.binarySearch(ALTERNATIVE_OPERATOR_NAMES, asString); if (idx >= 0) { pushOneCharOrTwoCharToken(TokenKind.valueOf(asString), start, subarray); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java index 2ea0c544ae0e..a6d3e7cd43aa 100755 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java @@ -385,7 +385,7 @@ protected List reconcileParameters(List parameters) if (meta.isReturnParameter()) { param = declaredParams.get(getFunctionReturnName()); if (param == null && !getOutParameterNames().isEmpty()) { - param = declaredParams.get(getOutParameterNames().get(0).toLowerCase()); + param = declaredParams.get(getOutParameterNames().get(0).toLowerCase(Locale.ROOT)); } if (param == null) { throw new InvalidDataAccessApiUsageException( @@ -488,7 +488,7 @@ public Map matchInParameterValuesWithCallParameters(SqlParameter String parameterName = parameter.getName(); String parameterNameToMatch = obtainMetaDataProvider().parameterNameToUse(parameterName); if (parameterNameToMatch != null) { - callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName); + callParameterNames.put(parameterNameToMatch.toLowerCase(Locale.ROOT), parameterName); } if (parameterName != null) { if (parameterSource.hasValue(parameterName)) { @@ -496,7 +496,7 @@ public Map matchInParameterValuesWithCallParameters(SqlParameter SqlParameterSourceUtils.getTypedValue(parameterSource, parameterName)); } else { - String lowerCaseName = parameterName.toLowerCase(); + String lowerCaseName = parameterName.toLowerCase(Locale.ROOT); if (parameterSource.hasValue(lowerCaseName)) { matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName)); @@ -556,7 +556,7 @@ else if (logger.isInfoEnabled()) { String parameterName = parameter.getName(); String parameterNameToMatch = provider.parameterNameToUse(parameterName); if (parameterNameToMatch != null) { - callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName); + callParameterNames.put(parameterNameToMatch.toLowerCase(Locale.ROOT), parameterName); } } } @@ -680,7 +680,7 @@ protected String createParameterBinding(SqlParameter parameter) { } private static String lowerCase(@Nullable String paramName) { - return (paramName != null ? paramName.toLowerCase() : ""); + return (paramName != null ? paramName.toLowerCase(Locale.ROOT) : ""); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/Db2CallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/Db2CallMetaDataProvider.java index 13904c9f340e..6743ce6c1f7a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/Db2CallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/Db2CallMetaDataProvider.java @@ -18,6 +18,7 @@ import java.sql.DatabaseMetaData; import java.sql.SQLException; +import java.util.Locale; import org.springframework.lang.Nullable; @@ -73,7 +74,7 @@ public String metaDataSchemaNameToUse(@Nullable String schemaName) { // Use current user schema if no schema specified... String userName = getUserName(); - return (userName != null ? userName.toUpperCase() : null); + return (userName != null ? userName.toUpperCase(Locale.ROOT) : null); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyCallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyCallMetaDataProvider.java index 02bbaa629f23..7430b379e2b4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyCallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/DerbyCallMetaDataProvider.java @@ -18,6 +18,7 @@ import java.sql.DatabaseMetaData; import java.sql.SQLException; +import java.util.Locale; import org.springframework.lang.Nullable; @@ -45,7 +46,7 @@ public String metaDataSchemaNameToUse(@Nullable String schemaName) { // Use current user schema if no schema specified... String userName = getUserName(); - return (userName != null ? userName.toUpperCase() : null); + return (userName != null ? userName.toUpperCase(Locale.ROOT) : null); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java index 789351ff5eee..10286861cb20 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java @@ -22,6 +22,7 @@ import java.sql.Types; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -279,10 +280,10 @@ private String identifierNameToUse(@Nullable String identifierName) { return null; } else if (isStoresUpperCaseIdentifiers()) { - return identifierName.toUpperCase(); + return identifierName.toUpperCase(Locale.ROOT); } else if (isStoresLowerCaseIdentifiers()) { - return identifierName.toLowerCase(); + return identifierName.toLowerCase(Locale.ROOT); } else { return identifierName; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java index 5228cb9b05cd..e10784e9c597 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.commons.logging.Log; @@ -230,10 +231,10 @@ public String tableNameToUse(@Nullable String tableName) { return null; } else if (isStoresUpperCaseIdentifiers()) { - return tableName.toUpperCase(); + return tableName.toUpperCase(Locale.ROOT); } else if (isStoresLowerCaseIdentifiers()) { - return tableName.toLowerCase(); + return tableName.toLowerCase(Locale.ROOT); } else { return tableName; @@ -247,10 +248,10 @@ public String catalogNameToUse(@Nullable String catalogName) { return null; } else if (isStoresUpperCaseIdentifiers()) { - return catalogName.toUpperCase(); + return catalogName.toUpperCase(Locale.ROOT); } else if (isStoresLowerCaseIdentifiers()) { - return catalogName.toLowerCase(); + return catalogName.toLowerCase(Locale.ROOT); } else { return catalogName; @@ -264,10 +265,10 @@ public String schemaNameToUse(@Nullable String schemaName) { return null; } else if (isStoresUpperCaseIdentifiers()) { - return schemaName.toUpperCase(); + return schemaName.toUpperCase(Locale.ROOT); } else if (isStoresLowerCaseIdentifiers()) { - return schemaName.toLowerCase(); + return schemaName.toLowerCase(Locale.ROOT); } else { return schemaName; @@ -322,10 +323,10 @@ private void locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, tmd.setSchemaName(tables.getString("TABLE_SCHEM")); tmd.setTableName(tables.getString("TABLE_NAME")); if (tmd.getSchemaName() == null) { - tableMeta.put(this.userName != null ? this.userName.toUpperCase() : "", tmd); + tableMeta.put(this.userName != null ? this.userName.toUpperCase(Locale.ROOT) : "", tmd); } else { - tableMeta.put(tmd.getSchemaName().toUpperCase(), tmd); + tableMeta.put(tmd.getSchemaName().toUpperCase(Locale.ROOT), tmd); } } } @@ -352,7 +353,7 @@ private TableMetaData findTableMetaData(@Nullable String schemaName, @Nullable S Map tableMeta) { if (schemaName != null) { - TableMetaData tmd = tableMeta.get(schemaName.toUpperCase()); + TableMetaData tmd = tableMeta.get(schemaName.toUpperCase(Locale.ROOT)); if (tmd == null) { throw new DataAccessResourceFailureException("Unable to locate table meta-data for '" + tableName + "' in the '" + schemaName + "' schema"); @@ -365,7 +366,7 @@ else if (tableMeta.size() == 1) { else { TableMetaData tmd = tableMeta.get(getDefaultSchema()); if (tmd == null) { - tmd = tableMeta.get(this.userName != null ? this.userName.toUpperCase() : ""); + tmd = tableMeta.get(this.userName != null ? this.userName.toUpperCase(Locale.ROOT) : ""); } if (tmd == null) { tmd = tableMeta.get("PUBLIC"); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java index be0ef871bc40..dd98823bc6e4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -192,11 +193,11 @@ protected List reconcileColumnsToUse(List declaredColumns, Strin } Set keys = new LinkedHashSet<>(generatedKeyNames.length); for (String key : generatedKeyNames) { - keys.add(key.toUpperCase()); + keys.add(key.toUpperCase(Locale.ROOT)); } List columns = new ArrayList<>(); for (TableParameterMetaData meta : obtainMetaDataProvider().getTableParameterMetaData()) { - if (!keys.contains(meta.getParameterName().toUpperCase())) { + if (!keys.contains(meta.getParameterName().toUpperCase(Locale.ROOT))) { columns.add(meta.getParameterName()); } } @@ -218,7 +219,7 @@ public List matchInParameterValuesWithInsertColumns(SqlParameterSource p values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, column)); } else { - String lowerCaseName = column.toLowerCase(); + String lowerCaseName = column.toLowerCase(Locale.ROOT); if (parameterSource.hasValue(lowerCaseName)) { values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName)); } @@ -251,7 +252,7 @@ public List matchInParameterValuesWithInsertColumns(Map inPar for (String column : this.tableColumns) { Object value = inParameters.get(column); if (value == null) { - value = inParameters.get(column.toLowerCase()); + value = inParameters.get(column.toLowerCase(Locale.ROOT)); if (value == null) { for (Map.Entry entry : inParameters.entrySet()) { if (column.equalsIgnoreCase(entry.getKey())) { @@ -274,7 +275,7 @@ public List matchInParameterValuesWithInsertColumns(Map inPar public String createInsertString(String... generatedKeyNames) { Set keys = new LinkedHashSet<>(generatedKeyNames.length); for (String key : generatedKeyNames) { - keys.add(key.toUpperCase()); + keys.add(key.toUpperCase(Locale.ROOT)); } StringBuilder insertStatement = new StringBuilder(); insertStatement.append("INSERT INTO "); @@ -286,7 +287,7 @@ public String createInsertString(String... generatedKeyNames) { insertStatement.append(" ("); int columnCount = 0; for (String columnName : getTableColumns()) { - if (!keys.contains(columnName.toUpperCase())) { + if (!keys.contains(columnName.toUpperCase(Locale.ROOT))) { columnCount++; if (columnCount > 1) { insertStatement.append(", "); @@ -326,7 +327,7 @@ public int[] createInsertTypes() { List parameters = obtainMetaDataProvider().getTableParameterMetaData(); Map parameterMap = CollectionUtils.newLinkedHashMap(parameters.size()); for (TableParameterMetaData tpmd : parameters) { - parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd); + parameterMap.put(tpmd.getParameterName().toUpperCase(Locale.ROOT), tpmd); } int typeIndx = 0; for (String column : getTableColumns()) { @@ -334,7 +335,7 @@ public int[] createInsertTypes() { types[typeIndx] = SqlTypeValue.TYPE_UNKNOWN; } else { - TableParameterMetaData tpmd = parameterMap.get(column.toUpperCase()); + TableParameterMetaData tpmd = parameterMap.get(column.toUpperCase(Locale.ROOT)); if (tpmd != null) { types[typeIndx] = tpmd.getSqlType(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java index ced04936cfa0..a99fa9d56348 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.springframework.jdbc.core.SqlParameterValue; @@ -115,7 +116,7 @@ public static Map extractCaseInsensitiveParameterNames(SqlParame String[] paramNames = parameterSource.getParameterNames(); if (paramNames != null) { for (String name : paramNames) { - caseInsensitiveParameterNames.put(name.toLowerCase(), name); + caseInsensitiveParameterNames.put(name.toLowerCase(Locale.ROOT), name); } } return caseInsensitiveParameterNames; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java index 504ee7013b7e..0b16c1c4130e 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.sql.DataSource; @@ -463,7 +464,7 @@ private KeyHolder executeInsertAndReturnKeyHolderInternal(List values) { // get generated keys feature. HSQL is one, PostgreSQL is another. Postgres uses a RETURNING // clause while HSQL uses a second query that has to be executed with the same connection. - if (keyQuery.toUpperCase().startsWith("RETURNING")) { + if (keyQuery.toUpperCase(Locale.ROOT).startsWith("RETURNING")) { Long key = getJdbcTemplate().queryForObject( getInsertString() + " " + keyQuery, Long.class, values.toArray()); Map keys = new HashMap<>(2); diff --git a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java index 0738ecfae1c7..38be7f3462f8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java @@ -16,6 +16,8 @@ package org.springframework.jms.config; +import java.util.Locale; + import javax.jms.Session; import org.w3c.dom.Element; @@ -154,7 +156,7 @@ protected MutablePropertyValues parseSpecificContainerProperties(Element contain } } else { - properties.add("cacheLevelName", "CACHE_" + cache.toUpperCase()); + properties.add("cacheLevelName", "CACHE_" + cache.toUpperCase(Locale.ROOT)); } } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java index 7d3981f5320d..4c44de2a18cc 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java @@ -406,7 +406,8 @@ public void setCharacterEncoding(@Nullable String characterEncoding) { private void updateContentTypeHeader() { if (StringUtils.hasLength(this.contentType)) { String value = this.contentType; - if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) { + if (StringUtils.hasLength(this.characterEncoding) && + !this.contentType.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) { value += ';' + CHARSET_PREFIX + this.characterEncoding; } doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true); @@ -484,7 +485,7 @@ public void setContentType(@Nullable String contentType) { } catch (IllegalArgumentException ex) { // Try to get charset value anyway - int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX); + int charsetIndex = contentType.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX); if (charsetIndex != -1) { this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length()); } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java index caeddbb69da3..219e9249a830 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java @@ -215,7 +215,7 @@ private void setExplicitCharacterEncoding(String characterEncoding) { private void updateContentTypePropertyAndHeader() { if (this.contentType != null) { String value = this.contentType; - if (this.characterEncodingSet && !value.toLowerCase().contains(CHARSET_PREFIX)) { + if (this.characterEncodingSet && !value.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) { value += ';' + CHARSET_PREFIX + getCharacterEncoding(); this.contentType = value; } @@ -315,7 +315,7 @@ public void setContentType(@Nullable String contentType) { } catch (Exception ex) { // Try to get charset value anyway - int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX); + int charsetIndex = contentType.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX); if (charsetIndex != -1) { setExplicitCharacterEncoding(contentType.substring(charsetIndex + CHARSET_PREFIX.length())); } diff --git a/spring-test/src/main/java/org/springframework/test/context/NestedTestConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/NestedTestConfiguration.java index 74e7ec91a179..cf30e3c2cc31 100644 --- a/spring-test/src/main/java/org/springframework/test/context/NestedTestConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/NestedTestConfiguration.java @@ -22,6 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.Locale; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -159,7 +160,7 @@ public static EnclosingConfiguration from(@Nullable String name) { return null; } try { - return EnclosingConfiguration.valueOf(name.trim().toUpperCase()); + return EnclosingConfiguration.valueOf(name.trim().toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ex) { Log logger = LogFactory.getLog(EnclosingConfiguration.class); diff --git a/spring-test/src/main/java/org/springframework/test/context/TestConstructor.java b/spring-test/src/main/java/org/springframework/test/context/TestConstructor.java index a2747456289e..70b85f4c98d6 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestConstructor.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestConstructor.java @@ -22,6 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.Locale; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -151,7 +152,7 @@ public static AutowireMode from(@Nullable String name) { return null; } try { - return AutowireMode.valueOf(name.trim().toUpperCase()); + return AutowireMode.valueOf(name.trim().toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ex) { Log logger = LogFactory.getLog(AutowireMode.class); diff --git a/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java b/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java index 22a9cfa8e332..686844b8ce71 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit/jupiter/AbstractExpressionEvaluatingCondition.java @@ -18,6 +18,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; +import java.util.Locale; import java.util.Optional; import java.util.function.Function; @@ -193,7 +194,7 @@ private boolean evaluateExpression(String expression, boo return (Boolean) result; } else if (result instanceof String) { - String str = ((String) result).trim().toLowerCase(); + String str = ((String) result).trim().toLowerCase(Locale.ROOT); if ("true".equals(str)) { return true; } diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index 5fe14a360be4..7c2442427cea 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -391,7 +391,7 @@ public class HttpHeaders implements MultiValueMap, Serializable */ public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new LinkedMultiValueMap<>()); - private static final DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = new DecimalFormatSymbols(Locale.ENGLISH); + private static final DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = new DecimalFormatSymbols(Locale.ROOT); private static final ZoneId GMT = ZoneId.of("GMT"); @@ -420,7 +420,7 @@ public class HttpHeaders implements MultiValueMap, Serializable *

This is the common constructor, using a case-insensitive map structure. */ public HttpHeaders() { - this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))); + this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ROOT))); } /** @@ -684,7 +684,7 @@ public HttpMethod getAccessControlRequestMethod() { public void setAcceptCharset(List acceptableCharsets) { StringJoiner joiner = new StringJoiner(", "); for (Charset charset : acceptableCharsets) { - joiner.add(charset.name().toLowerCase(Locale.ENGLISH)); + joiner.add(charset.name().toLowerCase(Locale.ROOT)); } set(ACCEPT_CHARSET, joiner.toString()); } diff --git a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java index b61cfea07350..f6da6eabf9c4 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java +++ b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java @@ -77,7 +77,7 @@ private static MultiValueMap parseMimeTypes() { String[] tokens = StringUtils.tokenizeToStringArray(line, " \t\n\r\f"); MediaType mediaType = MediaType.parseMediaType(tokens[0]); for (int i = 1; i < tokens.length; i++) { - String fileExtension = tokens[i].toLowerCase(Locale.ENGLISH); + String fileExtension = tokens[i].toLowerCase(Locale.ROOT); result.add(fileExtension, mediaType); } } @@ -117,7 +117,7 @@ public static List getMediaTypes(@Nullable String filename) { List mediaTypes = null; String ext = StringUtils.getFilenameExtension(filename); if (ext != null) { - mediaTypes = fileExtensionToMediaTypes.get(ext.toLowerCase(Locale.ENGLISH)); + mediaTypes = fileExtensionToMediaTypes.get(ext.toLowerCase(Locale.ROOT)); } return (mediaTypes != null ? mediaTypes : Collections.emptyList()); } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java index 4a86019c74e0..8ad154927bf0 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java @@ -107,7 +107,7 @@ public ServletServerHttpRequest(MultiValueMap headers, HttpServl private static MultiValueMap createDefaultHttpHeaders(HttpServletRequest request) { MultiValueMap headers = - CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)); + CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ROOT)); for (Enumeration names = request.getHeaderNames(); names.hasMoreElements(); ) { String name = (String) names.nextElement(); for (Enumeration values = request.getHeaders(name); values.hasMoreElements(); ) { diff --git a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java index c8a278fec427..5949cd4a3087 100644 --- a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java +++ b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java @@ -364,7 +364,7 @@ protected InputStream getResponseBody(HttpInvokerClientConfiguration config, Htt protected boolean isGzipResponse(HttpResponse httpResponse) { Header encodingHeader = httpResponse.getFirstHeader(HTTP_HEADER_CONTENT_ENCODING); return (encodingHeader != null && encodingHeader.getValue() != null && - encodingHeader.getValue().toLowerCase().contains(ENCODING_GZIP)); + encodingHeader.getValue().toLowerCase(Locale.ROOT).contains(ENCODING_GZIP)); } } diff --git a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java index b4c8f31c364b..0cfdd3eff2a3 100644 --- a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java +++ b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java @@ -227,7 +227,7 @@ protected InputStream readResponseBody(HttpInvokerClientConfiguration config, Ht */ protected boolean isGzipResponse(HttpURLConnection con) { String encodingHeader = con.getHeaderField(HTTP_HEADER_CONTENT_ENCODING); - return (encodingHeader != null && encodingHeader.toLowerCase().contains(ENCODING_GZIP)); + return (encodingHeader != null && encodingHeader.toLowerCase(Locale.ROOT).contains(ENCODING_GZIP)); } } diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index c23db8e97c9c..d4506f2b18fb 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -214,7 +214,7 @@ public void setMediaTypes(Properties mediaTypes) { * An alternative to {@link #setMediaTypes} for programmatic registrations. */ public void addMediaType(String key, MediaType mediaType) { - this.mediaTypes.put(key.toLowerCase(Locale.ENGLISH), mediaType); + this.mediaTypes.put(key.toLowerCase(Locale.ROOT), mediaType); } /** diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java index a0ee49a56953..c5ad7cc706ce 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java +++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java @@ -57,7 +57,7 @@ public MappingMediaTypeFileExtensionResolver(@Nullable Map me if (mediaTypes != null) { Set allFileExtensions = new HashSet<>(mediaTypes.size()); mediaTypes.forEach((extension, mediaType) -> { - String lowerCaseExtension = extension.toLowerCase(Locale.ENGLISH); + String lowerCaseExtension = extension.toLowerCase(Locale.ROOT); this.mediaTypes.put(lowerCaseExtension, mediaType); addFileExtension(mediaType, lowerCaseExtension); allFileExtensions.add(lowerCaseExtension); @@ -109,7 +109,7 @@ public List getAllFileExtensions() { */ @Nullable protected MediaType lookupMediaType(String extension) { - return this.mediaTypes.get(extension.toLowerCase(Locale.ENGLISH)); + return this.mediaTypes.get(extension.toLowerCase(Locale.ROOT); } } diff --git a/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java b/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java index 3fc337b377b6..4b4de9eb2d95 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java +++ b/spring-web/src/main/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategy.java @@ -99,7 +99,7 @@ protected String getMediaTypeKey(NativeWebRequest webRequest) { // Ignore LOOKUP_PATH attribute, use our own "fixed" UrlPathHelper with decoding off String path = this.urlPathHelper.getLookupPathForRequest(request); String extension = UriUtils.extractFileExtension(path); - return (StringUtils.hasText(extension) ? extension.toLowerCase(Locale.ENGLISH) : null); + return (StringUtils.hasText(extension) ? extension.toLowerCase(Locale.ROOT) : null); } /** diff --git a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java index 4b0b2db90283..a6ad8498b408 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java @@ -73,7 +73,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { private static final Set FORWARDED_HEADER_NAMES = - Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ENGLISH)); + Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ROOT)); static { FORWARDED_HEADER_NAMES.add("Forwarded"); @@ -177,7 +177,7 @@ public ForwardedHeaderRemovingRequest(HttpServletRequest request) { } private static Map> initHeaders(HttpServletRequest request) { - Map> headers = new LinkedCaseInsensitiveMap<>(Locale.ENGLISH); + Map> headers = new LinkedCaseInsensitiveMap<>(Locale.ROOT); Enumeration names = request.getHeaderNames(); while (names.hasMoreElements()) { String name = names.nextElement(); diff --git a/spring-web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java b/spring-web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java index 0ed01daa40cb..2546ae6746d7 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java @@ -84,7 +84,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse if ("POST".equals(request.getMethod()) && request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE) == null) { String paramValue = request.getParameter(this.methodParam); if (StringUtils.hasLength(paramValue)) { - String method = paramValue.toUpperCase(Locale.ENGLISH); + String method = paramValue.toUpperCase(Locale.ROOT); if (ALLOWED_METHODS.contains(method)) { requestToUse = new HttpMethodRequestWrapper(request, method); } diff --git a/spring-web/src/main/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilter.java b/spring-web/src/main/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilter.java index 90d18497169c..664b9581982d 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilter.java @@ -91,7 +91,7 @@ public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { } private ServerWebExchange mapExchange(ServerWebExchange exchange, String methodParamValue) { - HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ENGLISH)); + HttpMethod httpMethod = HttpMethod.resolve(methodParamValue.toUpperCase(Locale.ROOT)); Assert.notNull(httpMethod, () -> "HttpMethod '" + methodParamValue + "' not supported"); if (ALLOWED_METHODS.contains(httpMethod)) { return exchange.mutate().request(builder -> builder.method(httpMethod)).build(); diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java index 7d554e9052d7..e01cb8e91cc7 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Locale; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.Part; @@ -71,7 +72,7 @@ public static boolean isMultipartRequest(HttpServletRequest request) { private static boolean isMultipartContent(HttpServletRequest request) { String contentType = request.getContentType(); - return (contentType != null && contentType.toLowerCase().startsWith("multipart/")); + return (contentType != null && contentType.toLowerCase(Locale.ROOT).startsWith("multipart/")); } static MultipartHttpServletRequest asMultipartHttpServletRequest(HttpServletRequest request) { diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java index 88bfdd4f2aa9..321fba49d58c 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java @@ -29,6 +29,7 @@ import java.util.Enumeration; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -119,7 +120,7 @@ private void parseRequest(HttpServletRequest request) { protected void handleParseFailure(Throwable ex) { String msg = ex.getMessage(); if (msg != null) { - msg = msg.toLowerCase(); + msg = msg.toLowerCase(Locale.ROOT); if (msg.contains("size") && msg.contains("exceed")) { throw new MaxUploadSizeExceededException(-1, ex); } diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/ForwardedHeaderTransformer.java b/spring-web/src/main/java/org/springframework/web/server/adapter/ForwardedHeaderTransformer.java index fac2f1acfad8..c8852c8b3c5e 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/ForwardedHeaderTransformer.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/ForwardedHeaderTransformer.java @@ -57,7 +57,7 @@ public class ForwardedHeaderTransformer implements Function { static final Set FORWARDED_HEADER_NAMES = - Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ENGLISH)); + Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(10, Locale.ROOT)); static { FORWARDED_HEADER_NAMES.add("Forwarded"); diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java index 76cae2917861..3611471c0c74 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java @@ -18,6 +18,7 @@ import java.util.Arrays; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import org.apache.commons.logging.Log; @@ -314,7 +315,7 @@ else if (lostClientLogger.isDebugEnabled()) { private boolean isDisconnectedClientError(Throwable ex) { String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage(); if (message != null) { - String text = message.toLowerCase(); + String text = message.toLowerCase(Locale.ROOT); if (text.contains("broken pipe") || text.contains("connection reset by peer")) { return true; } diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index 4d1d07c808ad..7029638c2a70 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -26,6 +26,7 @@ import java.util.Deque; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; @@ -291,7 +292,7 @@ public static UriComponentsBuilder fromHttpUrl(String httpUrl) { if (matcher.matches()) { UriComponentsBuilder builder = new UriComponentsBuilder(); String scheme = matcher.group(1); - builder.scheme(scheme != null ? scheme.toLowerCase() : null); + builder.scheme(scheme != null ? scheme.toLowerCase(Locale.ROOT) : null); builder.userInfo(matcher.group(4)); String host = matcher.group(5); checkSchemeAndHost(httpUrl, scheme, host); diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java index d347cd516ae4..0da913adbd84 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -18,6 +18,7 @@ import java.net.URLDecoder; import java.nio.charset.UnsupportedCharsetException; +import java.util.Locale; import java.util.Map; import java.util.Properties; @@ -635,7 +636,7 @@ private static String removeSemicolonContentInternal(String requestUri) { private String removeJsessionid(String requestUri) { String key = ";jsessionid="; - int index = requestUri.toLowerCase().indexOf(key); + int index = requestUri.toLowerCase(Locale.ROOT).indexOf(key); if (index == -1) { return requestUri; } diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java index 4ae702d55111..c94ce609c545 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java @@ -187,7 +187,7 @@ protected void assertHttpMethod(String path, HttpMethod method) throws Exception Future futureResponse = request.executeAsync(); try (ClientHttpResponse response = futureResponse.get()) { assertThat(response.getStatusCode()).as("Invalid response status").isEqualTo(HttpStatus.OK); - assertThat(request.getMethod().name()).as("Invalid method").isEqualTo(path.toUpperCase(Locale.ENGLISH)); + assertThat(request.getMethod().name()).as("Invalid method").isEqualTo(path.toUpperCase(Locale.ROOT)); } } diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java index f231495ddf97..d208f249545a 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java @@ -167,7 +167,7 @@ protected void assertHttpMethod(String path, HttpMethod method) throws Exception try (ClientHttpResponse response = request.execute()) { assertThat(response.getStatusCode()).as("Invalid response status").isEqualTo(HttpStatus.OK); - assertThat(request.getMethod().name()).as("Invalid method").isEqualTo(path.toUpperCase(Locale.ENGLISH)); + assertThat(request.getMethod().name()).as("Invalid method").isEqualTo(path.toUpperCase(Locale.ROOT)); } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/accept/ParameterContentTypeResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/accept/ParameterContentTypeResolver.java index e8a6f6bad0ab..94d18d3e38be 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/accept/ParameterContentTypeResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/accept/ParameterContentTypeResolver.java @@ -51,7 +51,7 @@ public ParameterContentTypeResolver(Map mediaTypes) { } private static String formatKey(String key) { - return key.toLowerCase(Locale.ENGLISH); + return key.toLowerCase(Locale.ROOT); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java index 015b3889172d..d6cde0b03488 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceResolver.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; import reactor.core.publisher.Mono; @@ -140,7 +141,7 @@ private String getContentCodingKey(ServerWebExchange exchange) { return Arrays.stream(StringUtils.tokenizeToStringArray(header, ",")) .map(token -> { int index = token.indexOf(';'); - return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(); + return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(Locale.ROOT); }) .filter(this.contentCodings::contains) .sorted() diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java index 1bbdb443011d..dc1460bb98f2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/EncodedResourceResolver.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import reactor.core.publisher.Mono; @@ -168,7 +169,7 @@ protected Mono resolveResourceInternal(@Nullable ServerWebExchange exc private String getAcceptEncoding(ServerWebExchange exchange) { ServerHttpRequest request = exchange.getRequest(); String header = request.getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING); - return (header != null ? header.toLowerCase() : null); + return (header != null ? header.toLowerCase(Locale.ROOT) : null); } private String getExtension(String coding) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java index 74a7a628bb9b..0b2958ee19d2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/GzipResourceResolver.java @@ -22,6 +22,7 @@ import java.net.URI; import java.net.URL; import java.util.List; +import java.util.Locale; import reactor.core.publisher.Mono; @@ -69,7 +70,7 @@ protected Mono resolveResourceInternal(@Nullable ServerWebExchange exc private boolean isGzipAccepted(ServerWebExchange exchange) { String value = exchange.getRequest().getHeaders().getFirst("Accept-Encoding"); - return (value != null && value.toLowerCase().contains("gzip")); + return (value != null && value.toLowerCase(Locale.ROOT).contains("gzip")); } @Override diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java index 7c4db588b450..959c69e1caa5 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java @@ -315,7 +315,7 @@ public void setMediaTypes(Map mediaTypes) { this.mediaTypes = new HashMap<>(mediaTypes.size()); } mediaTypes.forEach((ext, type) -> - this.mediaTypes.put(ext.toLowerCase(Locale.ENGLISH), type)); + this.mediaTypes.put(ext.toLowerCase(Locale.ROOT), type)); } /** @@ -605,7 +605,7 @@ private MediaType getMediaType(Resource resource) { if (!CollectionUtils.isEmpty(this.mediaTypes)) { String ext = StringUtils.getFilenameExtension(filename); if (ext != null) { - mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ENGLISH)); + mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ROOT); } } if (mediaType == null) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java index 37b4ee985842..5ff406980ff9 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractNameValueExpression.java @@ -16,6 +16,8 @@ package org.springframework.web.reactive.result.condition; +import java.util.Locale; + import org.springframework.lang.Nullable; import org.springframework.util.ObjectUtils; import org.springframework.web.server.ServerWebExchange; @@ -106,7 +108,7 @@ public boolean equals(@Nullable Object other) { @Override public int hashCode() { - int result = (isCaseSensitiveName() ? this.name : this.name.toLowerCase()).hashCode(); + int result = (isCaseSensitiveName() ? this.name : this.name.toLowerCase(Locale.ROOT)).hashCode(); result = 31 * result + ObjectUtils.nullSafeHashCode(this.value); result = 31 * result + (this.isNegated ? 1 : 0); return result; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java index 5acc07c3dc44..3a32554c5181 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractNameValueExpression.java @@ -16,6 +16,8 @@ package org.springframework.web.servlet.mvc.condition; +import java.util.Locale; + import javax.servlet.http.HttpServletRequest; import org.springframework.lang.Nullable; @@ -108,7 +110,7 @@ public boolean equals(@Nullable Object other) { @Override public int hashCode() { - int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase().hashCode()); + int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase(Locale.ROOT).hashCode()); result = 31 * result + (this.value != null ? this.value.hashCode() : 0); result = 31 * result + (this.isNegated ? 1 : 0); return result; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java index 8152b9194744..f50948fd73cc 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java @@ -456,7 +456,7 @@ private boolean safeExtension(HttpServletRequest request, @Nullable String exten if (!StringUtils.hasText(extension)) { return true; } - extension = extension.toLowerCase(Locale.ENGLISH); + extension = extension.toLowerCase(Locale.ROOT); if (this.safeExtensions.contains(extension)) { return true; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java index 762c84884150..82eb8c58196f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; @@ -146,7 +147,7 @@ private String getContentCodingKey(HttpServletRequest request) { return Arrays.stream(StringUtils.tokenizeToStringArray(header, ",")) .map(token -> { int index = token.indexOf(';'); - return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(); + return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(Locale.ROOT); }) .filter(this.contentCodings::contains) .sorted() diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java index c4dbaa038df3..430aa729163d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResourceResolver.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -164,7 +165,7 @@ protected Resource resolveResourceInternal(@Nullable HttpServletRequest request, @Nullable private String getAcceptEncoding(HttpServletRequest request) { String header = request.getHeader(HttpHeaders.ACCEPT_ENCODING); - return (header != null ? header.toLowerCase() : null); + return (header != null ? header.toLowerCase(Locale.ROOT) : null); } private String getExtension(String coding) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java index f7b8542befae..d3b47f98eb2b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java @@ -22,6 +22,7 @@ import java.net.URI; import java.net.URL; import java.util.List; +import java.util.Locale; import javax.servlet.http.HttpServletRequest; @@ -70,7 +71,7 @@ protected Resource resolveResourceInternal(@Nullable HttpServletRequest request, private boolean isGzipAccepted(HttpServletRequest request) { String value = request.getHeader("Accept-Encoding"); - return (value != null && value.toLowerCase().contains("gzip")); + return (value != null && value.toLowerCase(Locale.ROOT).contains("gzip")); } @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index f5a1ada29408..5146eb51ded3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -317,7 +317,7 @@ public ContentNegotiationManager getContentNegotiationManager() { */ public void setMediaTypes(Map mediaTypes) { mediaTypes.forEach((ext, mediaType) -> - this.mediaTypes.put(ext.toLowerCase(Locale.ENGLISH), mediaType)); + this.mediaTypes.put(ext.toLowerCase(Locale.ROOT), mediaType)); } /** @@ -786,7 +786,7 @@ protected MediaType getMediaType(HttpServletRequest request, Resource resource) String filename = resource.getFilename(); String ext = StringUtils.getFilenameExtension(filename); if (ext != null) { - mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ENGLISH)); + mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ROOT); } if (mediaType == null) { List mediaTypes = MediaTypeFactory.getMediaTypes(filename); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java index e0383c5e3227..7966e2d1d392 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java @@ -20,6 +20,7 @@ import java.io.InputStream; import java.io.Reader; import java.util.Enumeration; +import java.util.Locale; import java.util.Map; import java.util.Properties; @@ -415,7 +416,7 @@ protected void configureResponse(Map model, HttpServletResponse } if (StringUtils.hasText(encoding)) { // Only apply encoding if content type is specified but does not contain charset clause already. - if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) { + if (contentType != null && !contentType.toLowerCase(Locale.ROOT).contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) { contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding; } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java index da31a3b8c4e4..5cb52dbcbf26 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java @@ -72,7 +72,7 @@ public WebSocketExtension(String name, @Nullable Map parameters) Assert.hasLength(name, "Extension name must not be empty"); this.name = name; if (!CollectionUtils.isEmpty(parameters)) { - Map map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH); + Map map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT); map.putAll(parameters); this.parameters = Collections.unmodifiableMap(map); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java index 64692d494001..e88a5c8ff5fe 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java @@ -42,7 +42,7 @@ public StandardToWebSocketExtensionAdapter(Extension extension) { private static Map initParameters(Extension extension) { List parameters = extension.getParameters(); - Map result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH); + Map result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT); for (Extension.Parameter parameter : parameters) { result.put(parameter.getName(), parameter.getValue()); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java index 03cdeac6cfc8..192d23106db2 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -85,7 +86,7 @@ public final ListenableFuture doHandshake(WebSocketHandler web HttpHeaders headersToUse = new HttpHeaders(); if (headers != null) { headers.forEach((header, values) -> { - if (values != null && !specialHeaders.contains(header.toLowerCase())) { + if (values != null && !specialHeaders.contains(header.toLowerCase(Locale.ROOT))) { headersToUse.put(header, values); } }); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java index e942cb839240..afa6bdb4d560 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java @@ -181,7 +181,7 @@ private InetAddress getLocalHost() { private int getPort(URI uri) { if (uri.getPort() == -1) { - String scheme = uri.getScheme().toLowerCase(Locale.ENGLISH); + String scheme = uri.getScheme().toLowerCase(Locale.ROOT); return ("wss".equals(scheme) ? 443 : 80); } return uri.getPort(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java index 918c84298d5e..60d15caab5a4 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.commons.logging.Log; @@ -192,7 +193,7 @@ public RequestUpgradeStrategy getRequestUpgradeStrategy() { public void setSupportedProtocols(String... protocols) { this.supportedProtocols.clear(); for (String protocol : protocols) { - this.supportedProtocols.add(protocol.toLowerCase()); + this.supportedProtocols.add(protocol.toLowerCase(Locale.ROOT)); } } @@ -367,10 +368,10 @@ protected boolean isValidOrigin(ServerHttpRequest request) { protected String selectProtocol(List requestedProtocols, WebSocketHandler webSocketHandler) { List handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler); for (String protocol : requestedProtocols) { - if (handlerProtocols.contains(protocol.toLowerCase())) { + if (handlerProtocols.contains(protocol.toLowerCase(Locale.ROOT))) { return protocol; } - if (this.supportedProtocols.contains(protocol.toLowerCase())) { + if (this.supportedProtocols.contains(protocol.toLowerCase(Locale.ROOT))) { return protocol; } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java index dbf3461f8bc6..d89101d82bfc 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/frame/AbstractSockJsMessageCodec.java @@ -16,6 +16,8 @@ package org.springframework.web.socket.sockjs.frame; +import java.util.Locale; + import org.springframework.util.Assert; /** @@ -58,7 +60,7 @@ private String escapeSockJsSpecialChars(char[] characters) { for (char c : characters) { if (isSockJsSpecialChar(c)) { result.append('\\').append('u'); - String hex = Integer.toHexString(c).toLowerCase(); + String hex = Integer.toHexString(c).toLowerCase(Locale.ROOT); for (int i = 0; i < (4 - hex.length()); i++) { result.append('0'); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java index df2b745d53fb..bd69abdc5311 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java @@ -22,6 +22,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -364,7 +365,7 @@ else if (disconnectedClientLogger.isDebugEnabled()) { private boolean indicatesDisconnectedClient(Throwable ex) { String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage(); - message = (message != null ? message.toLowerCase() : ""); + message = (message != null ? message.toLowerCase(Locale.ROOT) : ""); String className = ex.getClass().getSimpleName(); return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className)); } diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc index 264a2227da09..2481097e8b40 100644 --- a/src/docs/asciidoc/testing.adoc +++ b/src/docs/asciidoc/testing.adoc @@ -2002,7 +2002,7 @@ test methods within that class are automatically disabled as well. Expressions can be any of the following: * <> (SpEL) expression. For example: - `@DisabledIf("#{systemProperties['os.name'].toLowerCase().contains('mac')}")` + `@DisabledIf("#{systemProperties['os.name'].toLowerCase(Locale.ROOT).contains('mac')}")` * Placeholder for a property available in the Spring <>. For example: `@DisabledIf("${smoke.tests.disabled}")` * Text literal. For example: `@DisabledIf("true")`