Merge branch '1.5.x'

This commit is contained in:
Stephane Nicoll 2018-02-26 18:03:32 +01:00
commit 306c79f0de
25 changed files with 82 additions and 45 deletions

View File

@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Mono;
@ -110,7 +112,7 @@ class CloudFoundrySecurityInterceptor {
String authorization = request.getHeaders().getFirst("Authorization");
String bearerPrefix = "bearer ";
if (authorization == null
|| !authorization.toLowerCase().startsWith(bearerPrefix)) {
|| !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION,
"Authorization header is missing or invalid");
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
@ -104,7 +106,7 @@ class CloudFoundrySecurityInterceptor {
String authorization = request.getHeader("Authorization");
String bearerPrefix = "bearer ";
if (authorization == null
|| !authorization.toLowerCase().startsWith(bearerPrefix)) {
|| !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION,
"Authorization header is missing or invalid");
}

View File

@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
@ -81,7 +82,7 @@ public class ExposeExcludePropertyEndpointFilter<E extends ExposableEndpoint<?>>
if (items == null) {
return Collections.emptySet();
}
return items.stream().map(String::toLowerCase)
return items.stream().map(item -> item.toLowerCase(Locale.ENGLISH))
.collect(Collectors.toCollection(HashSet::new));
}
@ -109,7 +110,7 @@ public class ExposeExcludePropertyEndpointFilter<E extends ExposableEndpoint<?>>
}
private boolean contains(Set<String> items, ExposableEndpoint<?> endpoint) {
return items.contains(endpoint.getId().toLowerCase());
return items.contains(endpoint.getId().toLowerCase(Locale.ENGLISH));
}
}

View File

@ -17,6 +17,7 @@
package org.springframework.boot.actuate.endpoint.invoke.reflect;
import java.lang.reflect.Method;
import java.util.Locale;
import org.springframework.boot.actuate.endpoint.OperationType;
import org.springframework.boot.actuate.endpoint.invoke.OperationParameters;
@ -81,8 +82,8 @@ public class OperationMethod {
@Override
public String toString() {
return "Operation " + this.operationType.name().toLowerCase() + " method "
+ this.method;
return "Operation " + this.operationType.name().toLowerCase(Locale.ENGLISH)
+ " method " + this.method;
}
}

View File

@ -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.
@ -16,6 +16,7 @@
package org.springframework.boot.actuate.health;
import java.util.Locale;
import java.util.function.Function;
/**
@ -28,7 +29,7 @@ public class HealthIndicatorNameFactory implements Function<String, String> {
@Override
public String apply(String name) {
int index = name.toLowerCase().indexOf("healthindicator");
int index = name.toLowerCase(Locale.ENGLISH).indexOf("healthindicator");
if (index > 0) {
return name.substring(0, index);
}

View File

@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -479,7 +480,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
string.append(StringUtils.collectionToCommaDelimitedString(this.types));
}
string.append("; SearchStrategy: ");
string.append(this.strategy.toString().toLowerCase());
string.append(this.strategy.toString().toLowerCase(Locale.ENGLISH));
string.append(")");
return string.toString();
}

View File

@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.session;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import javax.annotation.PostConstruct;
@ -252,7 +253,8 @@ public class SessionAutoConfiguration {
throw new SessionRepositoryUnavailableException("No session "
+ "repository could be auto-configured, check your "
+ "configuration (session store type is '"
+ storeType.name().toLowerCase() + "')", storeType);
+ storeType.name().toLowerCase(Locale.ENGLISH)
+ "')", storeType);
}
}
}

View File

@ -27,6 +27,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.jar.Manifest;
import groovy.lang.Grab;
@ -127,9 +128,10 @@ abstract class ArchiveCommand extends OptionParsingCommand {
+ this.type + " and at least one source file must be specified");
File output = new File((String) nonOptionArguments.remove(0));
Assert.isTrue(output.getName().toLowerCase().endsWith("." + this.type),
"The output '" + output + "' is not a " + this.type.toUpperCase()
+ " file.");
Assert.isTrue(
output.getName().toLowerCase(Locale.ENGLISH).endsWith("." + this.type),
"The output '" + output + "' is not a " + this.type.toUpperCase(
Locale.ENGLISH) + " file.");
deleteIfExists(output);
GroovyCompiler compiler = createCompiler(options);

View File

@ -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.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
@ -158,7 +159,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
matcher.group(1) + '-' + StringUtils.uncapitalize(matcher.group(2)));
}
matcher.appendTail(result);
return result.toString().toLowerCase();
return result.toString().toLowerCase(Locale.ENGLISH);
}
private String dotAppend(String prefix, String postfix) {

View File

@ -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

View File

@ -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.
@ -19,6 +19,7 @@ package org.springframework.boot.loader.tools;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
@ -42,7 +43,7 @@ public final class Layouts {
if (file == null) {
throw new IllegalArgumentException("File must not be null");
}
String lowerCaseFileName = file.getName().toLowerCase();
String lowerCaseFileName = file.getName().toLowerCase(Locale.ENGLISH);
if (lowerCaseFileName.endsWith(".jar")) {
return new Jar();
}

View File

@ -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.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import org.springframework.util.ReflectionUtils;
@ -123,7 +124,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");

View File

@ -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;
@ -488,7 +489,7 @@ public class PropertiesLauncher extends Launcher {
if (isNestedArchivePath(file)) {
return null;
}
String name = file.getName().toLowerCase();
String name = file.getName().toLowerCase(Locale.ENGLISH);
if (name.endsWith(".jar") || name.endsWith(".zip")) {
return new JarFileArchive(file);
}
@ -564,7 +565,7 @@ public class PropertiesLauncher extends Launcher {
if (path.startsWith("./")) {
path = path.substring(2);
}
String lowerCasePath = path.toLowerCase();
String lowerCasePath = path.toLowerCase(Locale.ENGLISH);
if (lowerCasePath.endsWith(".jar") || lowerCasePath.endsWith(".zip")) {
return path;
}

View File

@ -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;

View File

@ -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.
@ -16,6 +16,8 @@
package org.springframework.boot.ansi;
import java.util.Locale;
import org.springframework.util.Assert;
/**
@ -35,7 +37,7 @@ public abstract class AnsiOutput {
private static Boolean ansiCapable;
private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name")
.toLowerCase();
.toLowerCase(Locale.ENGLISH);
private static final String ENCODE_START = "\033[";

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
@ -250,7 +251,8 @@ public class ApplicationPidFileWriter
private final String[] properties;
SystemProperty(String name) {
this.properties = new String[] { name.toUpperCase(), name.toLowerCase() };
this.properties = new String[] { name.toUpperCase(Locale.ENGLISH),
name.toLowerCase(Locale.ENGLISH) };
}
@Override

View File

@ -18,6 +18,7 @@ package org.springframework.boot.context.logging;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@ -321,7 +322,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
if ("false".equalsIgnoreCase(level)) {
return LogLevel.OFF;
}
return LogLevel.valueOf(level.toUpperCase());
return LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH));
}
private void registerShutdownHookIfNecessary(Environment environment,

View File

@ -16,6 +16,8 @@
package org.springframework.boot.context.properties.source;
import java.util.Locale;
import org.springframework.boot.context.properties.source.ConfigurationPropertyName.Form;
/**
@ -76,7 +78,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
if (result.length() > 0) {
result.append("_");
}
result.append(name.getElement(i, Form.UNIFORM).toUpperCase());
result.append(name.getElement(i, Form.UNIFORM).toUpperCase(Locale.ENGLISH));
}
return result.toString();
}
@ -93,11 +95,11 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
}
private Object convertLegacyNameElement(String element) {
return element.replace('-', '_').toUpperCase();
return element.replace('-', '_').toUpperCase(Locale.ENGLISH);
}
private CharSequence processElementValue(CharSequence value) {
String result = value.toString().toLowerCase();
String result = value.toString().toLowerCase(Locale.ENGLISH);
return (isNumber(result) ? "[" + result + "]" : result);
}

View File

@ -19,6 +19,7 @@ package org.springframework.boot.jdbc;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@ -133,7 +134,7 @@ public enum DatabaseDriver {
@Override
protected boolean matchProductName(String productName) {
return super.matchProductName(productName)
|| productName.toLowerCase().startsWith("firebird");
|| productName.toLowerCase(Locale.ENGLISH).startsWith("firebird");
}
},
@ -146,7 +147,7 @@ public enum DatabaseDriver {
@Override
protected boolean matchProductName(String productName) {
return super.matchProductName(productName)
|| productName.toLowerCase().startsWith("db2/");
|| productName.toLowerCase(Locale.ENGLISH).startsWith("db2/");
}
},
@ -170,7 +171,7 @@ public enum DatabaseDriver {
@Override
protected boolean matchProductName(String productName) {
return super.matchProductName(productName)
|| productName.toLowerCase().contains("as/400");
|| productName.toLowerCase(Locale.ENGLISH).contains("as/400");
}
},
@ -222,7 +223,7 @@ public enum DatabaseDriver {
* @return the identifier
*/
public String getId() {
return name().toLowerCase();
return name().toLowerCase(Locale.ENGLISH);
}
protected boolean matchProductName(String productName) {
@ -230,7 +231,7 @@ public enum DatabaseDriver {
}
protected Collection<String> getUrlPrefixes() {
return Collections.singleton(this.name().toLowerCase());
return Collections.singleton(this.name().toLowerCase(Locale.ENGLISH));
}
/**
@ -265,7 +266,8 @@ public enum DatabaseDriver {
public static DatabaseDriver fromJdbcUrl(String url) {
if (StringUtils.hasLength(url)) {
Assert.isTrue(url.startsWith("jdbc"), "URL must start with 'jdbc'");
String urlWithoutPrefix = url.substring("jdbc".length()).toLowerCase();
String urlWithoutPrefix = url.substring("jdbc".length())
.toLowerCase(Locale.ENGLISH);
for (DatabaseDriver driver : values()) {
for (String urlPrefix : driver.getUrlPrefixes()) {
String prefix = ":" + urlPrefix + ":";

View File

@ -18,6 +18,7 @@ package org.springframework.boot.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Locale;
import javax.sql.DataSource;
@ -155,7 +156,7 @@ public enum EmbeddedDatabaseConnection {
if (productName == null) {
return false;
}
productName = productName.toUpperCase();
productName = productName.toUpperCase(Locale.ENGLISH);
EmbeddedDatabaseConnection[] candidates = EmbeddedDatabaseConnection.values();
for (EmbeddedDatabaseConnection candidate : candidates) {
if (candidate != NONE && productName.contains(candidate.name())) {

View File

@ -17,6 +17,7 @@
package org.springframework.boot.web.context;
import java.io.File;
import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -111,10 +112,10 @@ public class WebServerPortFileWriter
String extension = StringUtils.getFilenameExtension(this.file.getName());
name = name.substring(0, name.length() - extension.length() - 1);
if (isUpperCase(name)) {
name = name + "-" + namespace.toUpperCase();
name = name + "-" + namespace.toUpperCase(Locale.ENGLISH);
}
else {
name = name + "-" + namespace.toLowerCase();
name = name + "-" + namespace.toLowerCase(Locale.ENGLISH);
}
if (StringUtils.hasLength(extension)) {
name = name + "." + extension;

View File

@ -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.
@ -16,6 +16,8 @@
package org.springframework.boot.web.servlet;
import java.util.Locale;
import javax.servlet.MultipartConfigElement;
import org.springframework.util.Assert;
@ -110,7 +112,7 @@ public class MultipartConfigFactory {
private long parseSize(String size) {
Assert.hasLength(size, "Size must not be empty");
size = size.toUpperCase();
size = size.toUpperCase(Locale.ENGLISH);
if (size.endsWith("KB")) {
return Long.valueOf(size.substring(0, size.length() - 2)) * 1024;
}

View File

@ -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.
@ -22,6 +22,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.security.CodeSource;
import java.util.Arrays;
import java.util.Locale;
import org.apache.commons.logging.Log;
@ -81,7 +82,7 @@ class DocumentRoot {
this.logger.debug("Code archive: " + file);
}
if (file != null && file.exists() && !file.isDirectory()
&& file.getName().toLowerCase().endsWith(extension)) {
&& file.getName().toLowerCase(Locale.ENGLISH).endsWith(extension)) {
return file.getAbsoluteFile();
}
return null;

View File

@ -19,6 +19,7 @@ package org.springframework.boot.web.context;
import java.io.File;
import java.io.FileReader;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.junit.After;
@ -101,7 +102,7 @@ public class WebServerPortFileWriterTest {
@Test
public void createUpperCaseManagementPortFile() throws Exception {
File file = this.temporaryFolder.newFile();
file = new File(file.getParentFile(), file.getName().toUpperCase());
file = new File(file.getParentFile(), file.getName().toUpperCase(Locale.ENGLISH));
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("management", 9090));
String managementFile = file.getName();

View File

@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@ -312,7 +313,8 @@ public class SysVinitLaunchScriptIT {
private String buildImage(DockerClient docker) {
String dockerfile = "src/test/resources/conf/" + this.os + "/" + this.version
+ "/Dockerfile";
String tag = "spring-boot-it/" + this.os.toLowerCase() + ":" + this.version;
String tag = "spring-boot-it/" + this.os.toLowerCase(Locale.ENGLISH) + ":"
+ this.version;
BuildImageResultCallback resultCallback = new BuildImageResultCallback() {
private List<BuildResponseItem> items = new ArrayList<>();