Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated toLowerCase() and toUpperCase() to use Locale.ROOT #491

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -317,7 +318,7 @@ protected void deleteLocalApplicationResourceFile(AppDeploymentRequest appDeploy
* Delete maven resources if property is set.
*/
private Optional<File> fileToDelete(Resource resource) throws IOException {
String scheme = resource.getURI().getScheme().toLowerCase();
String scheme = resource.getURI().getScheme().toLowerCase(Locale.ROOT);
if (scheme.startsWith("http")) {
return Optional.of(resource.getFile());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -120,7 +121,7 @@ static class CfEnvResolver {
static boolean hasCfEnv(CfEnvAwareResource app
) {
try {
String scheme = app.getURI().getScheme().toLowerCase();
String scheme = app.getURI().getScheme().toLowerCase(Locale.ROOT);
if (scheme.equals("docker")) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public QuartzCronExpression(String cronExpression) throws ParseException {
throw new IllegalArgumentException("cronExpression cannot be null");
}

this.cronExpression = cronExpression.toUpperCase(Locale.US);
this.cronExpression = cronExpression.toUpperCase(Locale.ROOT);

buildExpression(this.cronExpression);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -349,7 +350,7 @@ String createDeploymentId(AppDeploymentRequest request) {
deploymentId = String.format("%s-%s", groupId, request.getDefinition().getName());
}
// Kubernetes does not allow . in the name and does not allow uppercase in the name
return deploymentId.replace('.', '-').toLowerCase();
return deploymentId.replace('.', '-').toLowerCase(Locale.ROOT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -126,7 +127,7 @@ public Container create(ContainerConfiguration containerConfiguration) {
break;
case shell:
for (String key : request.getDefinition().getProperties().keySet()) {
String envVar = key.replace('.', '_').toUpperCase();
String envVar = key.replace('.', '_').toUpperCase(Locale.ROOT);
envVarsMap.put(envVar, request.getDefinition().getProperties().get(key));
envVarsMap.putAll(appAdminCredentials);

Expand All @@ -144,7 +145,7 @@ public Container create(ContainerConfiguration containerConfiguration) {
}

String cmdLineArgValue = cmdLineArg.substring(cmdLineArg.indexOf("=") + 1);
envVarsMap.put(cmdLineArgKey.replace('.', '_').toUpperCase(), cmdLineArgValue);
envVarsMap.put(cmdLineArgKey.replace('.', '_').toUpperCase(Locale.ROOT), cmdLineArgValue);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
Expand Down Expand Up @@ -1048,7 +1049,7 @@ EntryPointStyle determineEntryPointStyle(Map<String, String> deploymentPropertie

if (deployerPropertyValue != null) {
try {
entryPointStyle = EntryPointStyle.valueOf(deployerPropertyValue.toLowerCase());
entryPointStyle = EntryPointStyle.valueOf(deployerPropertyValue.toLowerCase(Locale.ROOT));
}
catch (IllegalArgumentException ignore) {
}
Expand All @@ -1067,7 +1068,7 @@ ProbeType determineProbeType(Map<String, String> deploymentProperties) {
this.propertyPrefix + ".probeType", null);

if (StringUtils.hasText(deployerPropertyValue)) {
probeType = ProbeType.valueOf(deployerPropertyValue.toUpperCase());
probeType = ProbeType.valueOf(deployerPropertyValue.toUpperCase(Locale.ROOT));
}

return probeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -364,7 +365,7 @@ protected void createService(AppDeploymentRequest request) {
if (createLoadBalancer == null) {
isCreateLoadBalancer = properties.isCreateLoadBalancer();
} else {
if ("true".equals(createLoadBalancer.toLowerCase())) {
if ("true".equals(createLoadBalancer.toLowerCase(Locale.ROOT))) {
isCreateLoadBalancer = true;
}
}
Expand All @@ -379,7 +380,7 @@ protected void createService(AppDeploymentRequest request) {

if (createNodePort != null) {
spec.withType("NodePort");
if (!"true".equals(createNodePort.toLowerCase())) {
if (!"true".equals(createNodePort.toLowerCase(Locale.ROOT))) {
try {
Integer nodePort = Integer.valueOf(createNodePort);
servicePort.setNodePort(nodePort);
Expand Down Expand Up @@ -462,7 +463,7 @@ private String formatServiceName(AppDeploymentRequest request, String appName) {
String serviceName = groupId == null ? String.format("%s", appName)
: String.format("%s-%s", groupId, appName);

return serviceName.replace('.', '-').toLowerCase();
return serviceName.replace('.', '-').toLowerCase(Locale.ROOT);
}

private Set<ServicePort> addAdditionalServicePorts(String additionalServicePorts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
Expand Down Expand Up @@ -231,7 +232,7 @@ protected String createDeploymentId(AppDeploymentRequest request) {
String hashid = hashids.encode(idToEncode);
String deploymentId = name + "-" + hashid;
// Kubernetes does not allow . in the name and does not allow uppercase in the name
return deploymentId.replace('.', '-').toLowerCase();
return deploymentId.replace('.', '-').toLowerCase(Locale.ROOT);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public String apply(String value) {

@Override
public String apply(String value) {
return (value.isEmpty() ? value : value.toLowerCase(Locale.ENGLISH));
return (value.isEmpty() ? value : value.toLowerCase(Locale.ROOT));
}

},
Expand All @@ -99,7 +99,7 @@ public String apply(String value) {

@Override
public String apply(String value) {
return (value.isEmpty() ? value : value.toUpperCase(Locale.ENGLISH));
return (value.isEmpty() ? value : value.toUpperCase(Locale.ROOT));
}

};
Expand Down Expand Up @@ -224,7 +224,7 @@ private static String separatedToCamelCase(String value,
}
StringBuilder builder = new StringBuilder();
for (String field : SEPARATED_TO_CAMEL_CASE_PATTERN.split(value)) {
field = (caseInsensitive ? field.toLowerCase(Locale.ENGLISH) : field);
field = (caseInsensitive ? field.toLowerCase(Locale.ROOT) : field);
builder.append(
builder.length() != 0 ? StringUtils.capitalize(field) : field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.cloud.deployer.spi.local;

import java.util.Locale;

/**
* Deployer utility functions.
*
Expand All @@ -33,6 +35,6 @@ public class LocalDeployerUtils {
protected static boolean isWindows() {
String osName = System.getProperty("os.name");

return osName != null && osName.toLowerCase().startsWith("windows");
return osName != null && osName.toLowerCase(Locale.ROOT).startsWith("windows");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
Expand Down Expand Up @@ -283,7 +284,7 @@ public void testActuatorOperations() {
Collections.singletonMap("configuredLevel", "debug"), Object.class);
loggers = actuatorOperations
.getFromActuator(deploymentId, id, "/loggers/org.springframework", Map.class);
assertThat(((String)loggers.get("configuredLevel")).toLowerCase()).isEqualTo("debug");
assertThat(((String)loggers.get("configuredLevel")).toLowerCase(Locale.ROOT)).isEqualTo("debug");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Container create(ContainerConfiguration containerConfiguration) {
break;
case shell:
for (String key : request.getDefinition().getProperties().keySet()) {
String envVar = key.replace('.', '_').toUpperCase();
String envVar = key.replace('.', '_').toUpperCase(Locale.ROOT);
envVarsMap.put(envVar, request.getDefinition().getProperties().get(key));
envVarsMap.putAll(appAdminCredentials);

Expand All @@ -144,7 +144,7 @@ public Container create(ContainerConfiguration containerConfiguration) {
}

String cmdLineArgValue = cmdLineArg.substring(cmdLineArg.indexOf("=") + 1);
envVarsMap.put(cmdLineArgKey.replace('.', '_').toUpperCase(), cmdLineArgValue);
envVarsMap.put(cmdLineArgKey.replace('.', '_').toUpperCase(Locale.ROOT), cmdLineArgValue);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ protected void createService(AppDeploymentRequest request) {
if (createLoadBalancer == null) {
isCreateLoadBalancer = properties.isCreateLoadBalancer();
} else {
if ("true".equals(createLoadBalancer.toLowerCase())) {
if ("true".equals(createLoadBalancer.toLowerCase(Locale.ROOT))) {
isCreateLoadBalancer = true;
}
}
Expand All @@ -379,7 +379,7 @@ protected void createService(AppDeploymentRequest request) {

if (createNodePort != null) {
spec.withType("NodePort");
if (!"true".equals(createNodePort.toLowerCase())) {
if (!"true".equals(createNodePort.toLowerCase(Locale.ROOT))) {
try {
Integer nodePort = Integer.valueOf(createNodePort);
servicePort.setNodePort(nodePort);
Expand Down Expand Up @@ -462,7 +462,7 @@ private String formatServiceName(AppDeploymentRequest request, String appName) {
String serviceName = groupId == null ? String.format("%s", appName)
: String.format("%s-%s", groupId, appName);

return serviceName.replace('.', '-').toLowerCase();
return serviceName.replace('.', '-').toLowerCase(Locale.ROOT);
}

private Set<ServicePort> addAdditionalServicePorts(String additionalServicePorts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public class LocalDeployerUtils {
protected static boolean isWindows() {
String osName = System.getProperty("os.name");

return osName != null && osName.toLowerCase().startsWith("windows");
return osName != null && osName.toLowerCase(Locale.ROOT).startsWith("windows");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public void testActuatorOperations() {
Collections.singletonMap("configuredLevel", "debug"), Object.class);
loggers = actuatorOperations
.getFromActuator(deploymentId, id, "/loggers/org.springframework", Map.class);
assertThat(((String)loggers.get("configuredLevel")).toLowerCase()).isEqualTo("debug");
assertThat(((String)loggers.get("configuredLevel")).toLowerCase(Locale.ROOT)).isEqualTo("debug");

}

Expand Down
Loading