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 0c33bd276e..9a9a7d8f30 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.beans.support; 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 class PropertyComparator implements Comparator { Object v1 = getPropertyValue(o1); Object v2 = getPropertyValue(o2); if (this.sortDefinition.isIgnoreCase() && (v1 instanceof String text1) && (v2 instanceof String text2)) { - v1 = text1.toLowerCase(); - v2 = text2.toLowerCase(); + v1 = text1.toLowerCase(Locale.ROOT); + v2 = text2.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 5e68e73318..fc8875b581 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.scheduling.quartz; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; +import java.util.Locale; import javax.sql.DataSource; @@ -156,7 +157,7 @@ public class LocalDataSourceJobStore extends JobStoreCMT { 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 abae18df61..a6c56fbe93 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 3124cc25b5..e1702c9a54 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.ChronoField; 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 @@ abstract class CronField { } private static String replaceOrdinals(String value, String[] list) { - value = value.toUpperCase(); + value = value.toUpperCase(Locale.ROOT); for (int i = 0; i < list.length; i++) { String replacement = Integer.toString(i + 1); value = StringUtils.replace(value, list[i], replacement); diff --git a/spring-core-test/src/main/java/org/springframework/aot/agent/InvocationsRecorderClassVisitor.java b/spring-core-test/src/main/java/org/springframework/aot/agent/InvocationsRecorderClassVisitor.java index 32cb0ddc0a..4e7daa8f41 100644 --- a/spring-core-test/src/main/java/org/springframework/aot/agent/InvocationsRecorderClassVisitor.java +++ b/spring-core-test/src/main/java/org/springframework/aot/agent/InvocationsRecorderClassVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.aot.agent; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import org.springframework.asm.ClassVisitor; @@ -40,6 +41,7 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes { private final ClassWriter classWriter; + public InvocationsRecorderClassVisitor() { this(new ClassWriter(ClassWriter.COMPUTE_MAXS)); } @@ -49,6 +51,7 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes { this.classWriter = classWriter; } + public boolean isTransformed() { return this.isTransformed; } @@ -64,6 +67,7 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes { return new InvocationsRecorderMethodVisitor(mv); } + @SuppressWarnings("deprecation") class InvocationsRecorderMethodVisitor extends MethodVisitor implements Opcodes { @@ -83,7 +87,6 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes { super(SpringAsmInfo.ASM_VERSION, mv); } - @Override public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) { if (isOpcodeSupported(opcode) && shouldRecordMethodCall(owner, name)) { @@ -116,7 +119,6 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes { super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments); } - private boolean shouldRecordMethodCall(String owner, String method) { String methodReference = owner + "#" + method; return instrumentedMethods.contains(methodReference); @@ -124,13 +126,12 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes { private String rewriteMethodName(String owner, String methodName) { int classIndex = owner.lastIndexOf('/'); - return owner.substring(classIndex + 1).toLowerCase() + methodName; + return owner.substring(classIndex + 1).toLowerCase(Locale.ROOT) + methodName; } private String rewriteDescriptor(int opcode, String owner, String name, String descriptor) { return (opcode == Opcodes.INVOKESTATIC || opcode == Opcodes.H_INVOKESTATIC) ? descriptor : "(L" + owner + ";" + descriptor.substring(1); } - } } diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java index e54534705f..694e85b876 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.core.convert.support; +import java.util.Locale; import java.util.Set; import org.springframework.core.convert.converter.Converter; @@ -43,7 +44,7 @@ final class StringToBooleanConverter implements Converter { if (value.isEmpty()) { return null; } - value = value.toLowerCase(); + value = value.toLowerCase(Locale.ROOT); if (trueValues.contains(value)) { return Boolean.TRUE; } diff --git a/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java b/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java index 6b5f2fa36a..ebea271253 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.core.env; +import java.util.Locale; import java.util.Map; import org.springframework.lang.Nullable; @@ -109,7 +110,7 @@ public class SystemEnvironmentPropertySource extends MapPropertySource { if (resolvedName != null) { return resolvedName; } - String uppercasedName = name.toUpperCase(); + String uppercasedName = name.toUpperCase(Locale.ROOT); if (!name.equals(uppercasedName)) { resolvedName = checkPropertyName(uppercasedName); if (resolvedName != null) { 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 02c302752c..9a2f12f1cd 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java @@ -24,6 +24,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; +import java.util.Locale; import org.springframework.lang.Nullable; @@ -306,7 +307,7 @@ public abstract class ResourceUtils { */ 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 2578cad7c9..27b6ccff35 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; @@ -46,7 +48,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 a0a67d89af..360e7598fa 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; @@ -58,7 +59,7 @@ public class TypeReference extends SpelNodeImpl { 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 cbfcaa871d..c6bbfbfc29 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.ArrayList; 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; @@ -755,7 +756,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { 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])); @@ -948,7 +949,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { } 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; } @@ -1044,7 +1045,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { if (t.getKind().hasPayload()) { return t.stringValue(); } - return t.kind.toString().toLowerCase(); + return t.kind.toString().toLowerCase(Locale.ROOT); } @Contract("_, null, _ -> fail; _, _, null -> fail") 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 8d80fc8a33..379ca5b222 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 @@ package org.springframework.expression.spel.standard; 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; @@ -457,7 +458,7 @@ class Tokenizer { // Check if this is the alternative (textual) representation of an operator (see // ALTERNATIVE_OPERATOR_NAMES). if (subarray.length == 2 || subarray.length == 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 6b84ceb1d0..fdc66aa1c3 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 @@ public class CallMetaDataContext { 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 class CallMetaDataContext { 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 class CallMetaDataContext { 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 @@ public class CallMetaDataContext { String parameterName = parameter.getName(); String parameterNameToMatch = provider.parameterNameToUse(parameterName); if (parameterNameToMatch != null) { - callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName); + callParameterNames.put(parameterNameToMatch.toLowerCase(Locale.ROOT), parameterName); } } } @@ -681,7 +681,7 @@ public class CallMetaDataContext { } 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 13904c9f34..66c4956468 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.jdbc.core.metadata; import java.sql.DatabaseMetaData; import java.sql.SQLException; +import java.util.Locale; import org.springframework.lang.Nullable; @@ -73,7 +74,7 @@ public class Db2CallMetaDataProvider extends GenericCallMetaDataProvider { // 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 02bbaa629f..efaa556cf6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.jdbc.core.metadata; import java.sql.DatabaseMetaData; import java.sql.SQLException; +import java.util.Locale; import org.springframework.lang.Nullable; @@ -45,7 +46,7 @@ public class DerbyCallMetaDataProvider extends GenericCallMetaDataProvider { // 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 36383fefc5..5eb124b063 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.SQLException; 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; @@ -284,10 +285,10 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { 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 6269c0d91a..b5e65f418b 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.ArrayList; 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; @@ -214,10 +215,10 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { 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; @@ -326,10 +327,10 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { TableMetaData tmd = new TableMetaData(tables.getString("TABLE_CAT"), tables.getString("TABLE_SCHEM"), tables.getString("TABLE_NAME")); if (tmd.schemaName() == 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.schemaName().toUpperCase(), tmd); + tableMeta.put(tmd.schemaName().toUpperCase(Locale.ROOT), tmd); } } } @@ -356,7 +357,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { 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"); @@ -369,7 +370,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { 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 bf69f2f7c4..e7cb34de8f 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 @@ -19,6 +19,7 @@ package org.springframework.jdbc.core.metadata; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -216,11 +217,11 @@ public class TableMetaDataContext { } Set keys = CollectionUtils.newLinkedHashSet(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()); } } @@ -242,7 +243,7 @@ public class TableMetaDataContext { 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)); } @@ -275,7 +276,7 @@ public class TableMetaDataContext { 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())) { @@ -297,7 +298,7 @@ public class TableMetaDataContext { public String createInsertString(String... generatedKeyNames) { Set keys = CollectionUtils.newLinkedHashSet(generatedKeyNames.length); for (String key : generatedKeyNames) { - keys.add(key.toUpperCase()); + keys.add(key.toUpperCase(Locale.ROOT)); } String identifierQuoteString = (isQuoteIdentifiers() ? @@ -325,7 +326,7 @@ public class TableMetaDataContext { 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(", "); @@ -365,7 +366,7 @@ public class TableMetaDataContext { 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()) { @@ -373,7 +374,7 @@ public class TableMetaDataContext { 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 89b3f832db..9709561eb2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.jdbc.core.namedparam; 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 abstract class SqlParameterSourceUtils { 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 979ae771a5..6b86dbb673 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import javax.sql.DataSource; @@ -490,7 +491,7 @@ public abstract class AbstractJdbcInsert { // 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 39ff7a719a..85d075415a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.jms.config; +import java.util.Locale; + import jakarta.jms.Session; import org.w3c.dom.Element; @@ -155,7 +157,7 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser { } } 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/test/context/NestedTestConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/NestedTestConfiguration.java index 8dc0e821b0..d7102667e0 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.Inherited; 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; @@ -166,7 +167,7 @@ public @interface NestedTestConfiguration { 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); @@ -178,7 +179,6 @@ public @interface NestedTestConfiguration { return null; } } - } } 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 b1cd00043f..3285ca6f5a 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.Inherited; 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; @@ -161,7 +162,7 @@ public @interface TestConstructor { 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 a124a6f72a..c93f477b55 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 @@ package org.springframework.test.context.junit.jupiter; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; +import java.util.Locale; import java.util.Optional; import java.util.function.Function; @@ -190,7 +191,7 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi return b; } else if (result instanceof String str) { - str = str.trim().toLowerCase(); + str = str.trim().toLowerCase(Locale.ROOT); if ("true".equals(str)) { return true; } 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 5a15fd0eb9..8a5a3905fa 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.web.socket.client; import java.net.URI; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -81,7 +82,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient { 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/server/support/AbstractHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java index 6dbcd697e3..6c05cfda70 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.ArrayList; 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; @@ -154,7 +155,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life public void setSupportedProtocols(String... protocols) { this.supportedProtocols.clear(); for (String protocol : protocols) { - this.supportedProtocols.add(protocol.toLowerCase()); + this.supportedProtocols.add(protocol.toLowerCase(Locale.ROOT)); } } @@ -329,10 +330,10 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life 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 044a4a7bce..05438ff718 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.web.socket.sockjs.frame; +import java.util.Locale; + import org.springframework.util.Assert; /** @@ -58,7 +60,7 @@ public abstract class AbstractSockJsMessageCodec implements SockJsMessageCodec { 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); result.append("0".repeat(Math.max(0, (4 - hex.length())))); result.append(hex); }