Use toLowerCase() and toUpperCase() with Locale.ENGLISH
This commit updates all `toLowerCase()` and `toUpperCase` invocations to use the variant that takes a `Locale` to avoid locale-specific side effect. Closes gh-12213
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
@@ -183,7 +184,7 @@ class JsonReader {
|
||||
private Deprecation.Level parseDeprecationLevel(String value) {
|
||||
if (value != null) {
|
||||
try {
|
||||
return Deprecation.Level.valueOf(value.toUpperCase());
|
||||
return Deprecation.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// let's use the default
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -197,7 +198,7 @@ public class ConfigurationMetadata {
|
||||
previous = current;
|
||||
|
||||
}
|
||||
return dashed.toString().toLowerCase();
|
||||
return dashed.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> List<T> flattenValues(Map<?, List<T>> map) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -21,6 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -45,13 +46,14 @@ public final class Layouts {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("File must not be null");
|
||||
}
|
||||
if (file.getName().toLowerCase().endsWith(".jar")) {
|
||||
if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
|
||||
return new Jar();
|
||||
}
|
||||
if (file.getName().toLowerCase().endsWith(".war")) {
|
||||
if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
|
||||
return new War();
|
||||
}
|
||||
if (file.isDirectory() || file.getName().toLowerCase().endsWith(".zip")) {
|
||||
if (file.isDirectory()
|
||||
|| file.getName().toLowerCase(Locale.ENGLISH).endsWith(".zip")) {
|
||||
return new Expanded();
|
||||
}
|
||||
throw new IllegalStateException("Unable to deduce layout for '" + file + "'");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2018 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.io.InputStreamReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -128,7 +129,8 @@ public class RunProcess {
|
||||
// There's a bug in the Windows VM (https://bugs.openjdk.java.net/browse/JDK-8023130)
|
||||
// that means we need to avoid inheritIO
|
||||
private static boolean isInheritIOBroken() {
|
||||
if (!System.getProperty("os.name", "none").toLowerCase().contains("windows")) {
|
||||
if (!System.getProperty("os.name", "none").toLowerCase(Locale.ENGLISH)
|
||||
.contains("windows")) {
|
||||
return false;
|
||||
}
|
||||
String runtime = System.getProperty("java.runtime.version");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
@@ -27,6 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Manifest;
|
||||
@@ -489,7 +490,7 @@ public class PropertiesLauncher extends Launcher {
|
||||
}
|
||||
|
||||
private Archive getArchive(File file) throws IOException {
|
||||
String name = file.getName().toLowerCase();
|
||||
String name = file.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (name.endsWith(".jar") || name.endsWith(".zip")) {
|
||||
return new JarFileArchive(file);
|
||||
}
|
||||
@@ -566,7 +567,8 @@ public class PropertiesLauncher extends Launcher {
|
||||
if (path.startsWith("./")) {
|
||||
path = path.substring(2);
|
||||
}
|
||||
if (path.toLowerCase().endsWith(".jar") || path.toLowerCase().endsWith(".zip")) {
|
||||
String lowercasePath = path.toLowerCase(Locale.ENGLISH);
|
||||
if (lowercasePath.endsWith(".jar") || lowercasePath.endsWith(".zip")) {
|
||||
return path;
|
||||
}
|
||||
if (path.endsWith("/*")) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.boot.loader.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -188,7 +189,8 @@ public abstract class SystemPropertyUtils {
|
||||
}
|
||||
if (propVal == null) {
|
||||
// Try uppercase with underscores as well.
|
||||
propVal = System.getenv(key.toUpperCase().replace('.', '_'));
|
||||
propVal = System.getenv(key.toUpperCase(Locale.ENGLISH)
|
||||
.replace('.', '_'));
|
||||
}
|
||||
if (propVal != null) {
|
||||
return propVal;
|
||||
|
||||
Reference in New Issue
Block a user