Commit b4a7e1d6 authored by Stephane Nicoll's avatar Stephane Nicoll

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
parent 915eaf34
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.cloudfoundry; package org.springframework.boot.actuate.cloudfoundry;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -107,7 +109,7 @@ class CloudFoundrySecurityInterceptor extends HandlerInterceptorAdapter { ...@@ -107,7 +109,7 @@ class CloudFoundrySecurityInterceptor extends HandlerInterceptorAdapter {
String authorization = request.getHeader("Authorization"); String authorization = request.getHeader("Authorization");
String bearerPrefix = "bearer "; String bearerPrefix = "bearer ";
if (authorization == null if (authorization == null
|| !authorization.toLowerCase().startsWith(bearerPrefix)) { || !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION, throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION,
"Authorization header is missing or invalid"); "Authorization header is missing or invalid");
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,6 +19,7 @@ package org.springframework.boot.actuate.endpoint; ...@@ -19,6 +19,7 @@ package org.springframework.boot.actuate.endpoint;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -104,7 +105,7 @@ public class DataSourcePublicMetrics implements PublicMetrics { ...@@ -104,7 +105,7 @@ public class DataSourcePublicMetrics implements PublicMetrics {
return "datasource.primary"; return "datasource.primary";
} }
if (name.length() > DATASOURCE_SUFFIX.length() if (name.length() > DATASOURCE_SUFFIX.length()
&& name.toLowerCase().endsWith(DATASOURCE_SUFFIX.toLowerCase())) { && name.toLowerCase(Locale.ENGLISH).endsWith(DATASOURCE_SUFFIX.toLowerCase())) {
name = name.substring(0, name.length() - DATASOURCE_SUFFIX.length()); name = name.substring(0, name.length() - DATASOURCE_SUFFIX.length());
} }
return "datasource." + name; return "datasource." + name;
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.endpoint; package org.springframework.boot.actuate.endpoint;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.springframework.boot.actuate.health.CompositeHealthIndicator; import org.springframework.boot.actuate.health.CompositeHealthIndicator;
...@@ -91,7 +92,7 @@ public class HealthEndpoint extends AbstractEndpoint<Health> { ...@@ -91,7 +92,7 @@ public class HealthEndpoint extends AbstractEndpoint<Health> {
* @return the key * @return the key
*/ */
private String getKey(String name) { private String getKey(String name) {
int index = name.toLowerCase().indexOf("healthindicator"); int index = name.toLowerCase(Locale.ENGLISH).indexOf("healthindicator");
if (index > 0) { if (index > 0) {
return name.substring(0, index); return name.substring(0, index);
} }
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,6 +24,7 @@ import java.lang.management.ThreadMXBean; ...@@ -24,6 +24,7 @@ import java.lang.management.ThreadMXBean;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import org.springframework.boot.actuate.metrics.Metric; import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
...@@ -188,7 +189,7 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered { ...@@ -188,7 +189,7 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
* @return a metric friendly name * @return a metric friendly name
*/ */
private String beautifyGcName(String name) { private String beautifyGcName(String name) {
return StringUtils.replace(name, " ", "_").toLowerCase(); return StringUtils.replace(name, " ", "_").toLowerCase(Locale.ENGLISH);
} }
} }
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.endpoint.jmx; package org.springframework.boot.actuate.endpoint.jmx;
import java.util.Locale;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.actuate.endpoint.Endpoint;
...@@ -52,7 +54,7 @@ public class LoggersEndpointMBean extends EndpointMBean { ...@@ -52,7 +54,7 @@ public class LoggersEndpointMBean extends EndpointMBean {
@ManagedOperation(description = "Set log level for a given logger") @ManagedOperation(description = "Set log level for a given logger")
public void setLogLevel(String loggerName, String logLevel) { public void setLogLevel(String loggerName, String logLevel) {
Assert.notNull(logLevel, "LogLevel must not be null"); Assert.notNull(logLevel, "LogLevel must not be null");
LogLevel level = LogLevel.valueOf(logLevel.toUpperCase()); LogLevel level = LogLevel.valueOf(logLevel.toUpperCase(Locale.ENGLISH));
getEndpoint().setLogLevel(loggerName, level); getEndpoint().setLogLevel(loggerName, level);
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,6 +20,7 @@ import java.security.Principal; ...@@ -20,6 +20,7 @@ import java.security.Principal;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -151,7 +152,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint ...@@ -151,7 +152,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
private HttpStatus getStatus(Health health) { private HttpStatus getStatus(Health health) {
String code = health.getStatus().getCode(); String code = health.getStatus().getCode();
if (code != null) { if (code != null) {
code = code.toLowerCase().replace('_', '-'); code = code.toLowerCase(Locale.ENGLISH).replace('_', '-');
for (String candidate : RelaxedNames.forCamelCase(code)) { for (String candidate : RelaxedNames.forCamelCase(code)) {
HttpStatus status = this.statusMapping.get(candidate); HttpStatus status = this.statusMapping.get(candidate);
if (status != null) { if (status != null) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.endpoint.mvc; package org.springframework.boot.actuate.endpoint.mvc;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.springframework.boot.actuate.endpoint.LoggersEndpoint; import org.springframework.boot.actuate.endpoint.LoggersEndpoint;
...@@ -78,7 +79,8 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { ...@@ -78,7 +79,8 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter {
private LogLevel getLogLevel(Map<String, String> configuration) { private LogLevel getLogLevel(Map<String, String> configuration) {
String level = configuration.get("configuredLevel"); String level = configuration.get("configuredLevel");
try { try {
return (level == null ? null : LogLevel.valueOf(level.toUpperCase())); return (level == null ? null
: LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH)));
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
throw new InvalidLogLevelException(level); throw new InvalidLogLevelException(level);
......
...@@ -23,6 +23,7 @@ import java.util.Enumeration; ...@@ -23,6 +23,7 @@ import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -165,7 +166,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order ...@@ -165,7 +166,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
Enumeration<String> names = request.getHeaderNames(); Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) { while (names.hasMoreElements()) {
String name = names.nextElement(); String name = names.nextElement();
if (!excludedHeaders.contains(name.toLowerCase())) { if (!excludedHeaders.contains(name.toLowerCase(Locale.ENGLISH))) {
headers.put(name, getHeaderValue(request, name)); headers.put(name, getHeaderValue(request, name));
} }
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.cache; package org.springframework.boot.autoconfigure.cache;
import java.util.Locale;
import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
...@@ -50,7 +52,8 @@ class CacheCondition extends SpringBootCondition { ...@@ -50,7 +52,8 @@ class CacheCondition extends SpringBootCondition {
} }
CacheType cacheType = CacheConfigurations CacheType cacheType = CacheConfigurations
.getType(((AnnotationMetadata) metadata).getClassName()); .getType(((AnnotationMetadata) metadata).getClassName());
String value = resolver.getProperty("type").replace('-', '_').toUpperCase(); String value = resolver.getProperty("type").replace('-', '_')
.toUpperCase(Locale.ENGLISH);
if (value.equals(cacheType.name())) { if (value.equals(cacheType.name())) {
return ConditionOutcome.match(message.because(value + " cache type")); return ConditionOutcome.match(message.because(value + " cache type"));
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,6 +24,7 @@ import java.util.Collections; ...@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
...@@ -399,7 +400,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit ...@@ -399,7 +400,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
string.append(StringUtils.collectionToCommaDelimitedString(this.types)); string.append(StringUtils.collectionToCommaDelimitedString(this.types));
} }
string.append("; SearchStrategy: "); string.append("; SearchStrategy: ");
string.append(this.strategy.toString().toLowerCase()); string.append(this.strategy.toString().toLowerCase(Locale.ENGLISH));
string.append(")"); string.append(")");
return string.toString(); return string.toString();
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.data.cassandra; package org.springframework.boot.autoconfigure.data.cassandra;
import java.util.List; import java.util.List;
import java.util.Locale;
import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session; import com.datastax.driver.core.Session;
...@@ -114,7 +115,8 @@ public class CassandraDataAutoConfiguration { ...@@ -114,7 +115,8 @@ public class CassandraDataAutoConfiguration {
session.setKeyspaceName(this.properties.getKeyspaceName()); session.setKeyspaceName(this.properties.getKeyspaceName());
String name = this.propertyResolver.getProperty("schemaAction", String name = this.propertyResolver.getProperty("schemaAction",
SchemaAction.NONE.name()); SchemaAction.NONE.name());
SchemaAction schemaAction = SchemaAction.valueOf(name.toUpperCase()); SchemaAction schemaAction = SchemaAction.valueOf(
name.toUpperCase(Locale.ENGLISH));
session.setSchemaAction(schemaAction); session.setSchemaAction(schemaAction);
return session; return session;
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.jdbc; ...@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.jdbc;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Locale;
import javax.sql.DataSource; import javax.sql.DataSource;
...@@ -173,7 +174,7 @@ public enum EmbeddedDatabaseConnection { ...@@ -173,7 +174,7 @@ public enum EmbeddedDatabaseConnection {
if (productName == null) { if (productName == null) {
return false; return false;
} }
productName = productName.toUpperCase(); productName = productName.toUpperCase(Locale.ENGLISH);
EmbeddedDatabaseConnection[] candidates = EmbeddedDatabaseConnection.values(); EmbeddedDatabaseConnection[] candidates = EmbeddedDatabaseConnection.values();
for (EmbeddedDatabaseConnection candidate : candidates) { for (EmbeddedDatabaseConnection candidate : candidates) {
if (candidate != NONE && productName.contains(candidate.name())) { if (candidate != NONE && productName.contains(candidate.name())) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import java.util.Locale;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
...@@ -100,7 +102,8 @@ public class SessionAutoConfiguration { ...@@ -100,7 +102,8 @@ public class SessionAutoConfiguration {
if (storeType != null) { if (storeType != null) {
throw new IllegalArgumentException("No session repository could be " throw new IllegalArgumentException("No session repository could be "
+ "auto-configured, check your configuration (session store " + "auto-configured, check your configuration (session store "
+ "type is '" + storeType.name().toLowerCase() + "')"); + "type is '" + storeType.name().toLowerCase(Locale.ENGLISH)
+ "')");
} }
throw new IllegalArgumentException("No Spring Session store is " throw new IllegalArgumentException("No Spring Session store is "
+ "configured: set the 'spring.session.store-type' property"); + "configured: set the 'spring.session.store-type' property");
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import java.util.Locale;
import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
...@@ -45,7 +47,8 @@ class SessionCondition extends SpringBootCondition { ...@@ -45,7 +47,8 @@ class SessionCondition extends SpringBootCondition {
return ConditionOutcome.noMatch( return ConditionOutcome.noMatch(
message.didNotFind("spring.session.store-type property").atAll()); message.didNotFind("spring.session.store-type property").atAll());
} }
String value = resolver.getProperty("store-type").replace('-', '_').toUpperCase(); String value = resolver.getProperty("store-type").replace('-', '_')
.toUpperCase(Locale.ENGLISH);
if (value.equals(sessionStoreType.name())) { if (value.equals(sessionStoreType.name())) {
return ConditionOutcome.match(message return ConditionOutcome.match(message
.found("spring.session.store-type property").items(sessionStoreType)); .found("spring.session.store-type property").items(sessionStoreType));
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.web; ...@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.web;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -78,7 +79,7 @@ public abstract class AbstractErrorController implements ErrorController { ...@@ -78,7 +79,7 @@ public abstract class AbstractErrorController implements ErrorController {
if (parameter == null) { if (parameter == null) {
return false; return false;
} }
return !"false".equals(parameter.toLowerCase()); return !"false".equals(parameter.toLowerCase(Locale.ENGLISH));
} }
protected HttpStatus getStatus(HttpServletRequest request) { protected HttpStatus getStatus(HttpServletRequest request) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -27,6 +27,7 @@ import java.net.URL; ...@@ -27,6 +27,7 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import groovy.lang.Grab; import groovy.lang.Grab;
...@@ -129,9 +130,10 @@ abstract class ArchiveCommand extends OptionParsingCommand { ...@@ -129,9 +130,10 @@ abstract class ArchiveCommand extends OptionParsingCommand {
+ this.type + " and at least one source file must be specified"); + this.type + " and at least one source file must be specified");
File output = new File((String) nonOptionArguments.remove(0)); File output = new File((String) nonOptionArguments.remove(0));
Assert.isTrue(output.getName().toLowerCase().endsWith("." + this.type), Assert.isTrue(
"The output '" + output + "' is not a " + this.type.toUpperCase() output.getName().toLowerCase(Locale.ENGLISH).endsWith("." + this.type),
+ " file."); "The output '" + output + "' is not a " + this.type.toUpperCase(
Locale.ENGLISH) + " file.");
deleteIfExists(output); deleteIfExists(output);
GroovyCompiler compiler = createCompiler(options); GroovyCompiler compiler = createCompiler(options);
......
...@@ -24,6 +24,7 @@ import java.util.Arrays; ...@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -306,7 +307,8 @@ public class SysVinitLaunchScriptIT { ...@@ -306,7 +307,8 @@ public class SysVinitLaunchScriptIT {
private String buildImage(DockerClient docker) { private String buildImage(DockerClient docker) {
String dockerfile = "src/test/resources/conf/" + this.os + "/" + this.version String dockerfile = "src/test/resources/conf/" + this.os + "/" + this.version
+ "/Dockerfile"; + "/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() { BuildImageResultCallback resultCallback = new BuildImageResultCallback() {
private List<BuildResponseItem> items = new ArrayList<BuildResponseItem>(); private List<BuildResponseItem> items = new ArrayList<BuildResponseItem>();
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,6 +19,7 @@ package sample.data.gemfire.service; ...@@ -19,6 +19,7 @@ package sample.data.gemfire.service;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
...@@ -126,7 +127,7 @@ public class GemstoneServiceImpl implements GemstoneService { ...@@ -126,7 +127,7 @@ public class GemstoneServiceImpl implements GemstoneService {
} }
Gemstone validate(Gemstone gemstone) { Gemstone validate(Gemstone gemstone) {
if (!APPROVED_GEMS.contains(gemstone.getName().toUpperCase())) { if (!APPROVED_GEMS.contains(gemstone.getName().toUpperCase(Locale.ENGLISH))) {
// NOTE if the Gemstone is not valid, throw error... // NOTE if the Gemstone is not valid, throw error...
// Should cause transaction to rollback in GemFire! // Should cause transaction to rollback in GemFire!
System.err.printf("Illegal Gemstone [%1$s]!%n", gemstone.getName()); System.err.printf("Illegal Gemstone [%1$s]!%n", gemstone.getName());
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,6 +23,7 @@ import java.util.Collections; ...@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
...@@ -158,7 +159,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?> ...@@ -158,7 +159,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
matcher.group(1) + '-' + StringUtils.uncapitalize(matcher.group(2))); matcher.group(1) + '-' + StringUtils.uncapitalize(matcher.group(2)));
} }
matcher.appendTail(result); matcher.appendTail(result);
return result.toString().toLowerCase(); return result.toString().toLowerCase(Locale.ENGLISH);
} }
private String dotAppend(String prefix, String postfix) { private String dotAppend(String prefix, String postfix) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,6 +23,7 @@ import java.nio.charset.Charset; ...@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -183,7 +184,7 @@ class JsonReader { ...@@ -183,7 +184,7 @@ class JsonReader {
private Deprecation.Level parseDeprecationLevel(String value) { private Deprecation.Level parseDeprecationLevel(String value) {
if (value != null) { if (value != null) {
try { try {
return Deprecation.Level.valueOf(value.toUpperCase()); return Deprecation.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
// let's use the default // let's use the default
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,6 +23,7 @@ import java.util.HashSet; ...@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -197,7 +198,7 @@ public class ConfigurationMetadata { ...@@ -197,7 +198,7 @@ public class ConfigurationMetadata {
previous = current; 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) { private static <T extends Comparable<T>> List<T> flattenValues(Map<?, List<T>> map) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -21,6 +21,7 @@ import java.util.Arrays; ...@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -45,13 +46,14 @@ public final class Layouts { ...@@ -45,13 +46,14 @@ public final class Layouts {
if (file == null) { if (file == null) {
throw new IllegalArgumentException("File must not be 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(); return new Jar();
} }
if (file.getName().toLowerCase().endsWith(".war")) { if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
return new 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(); return new Expanded();
} }
throw new IllegalStateException("Unable to deduce layout for '" + file + "'"); throw new IllegalStateException("Unable to deduce layout for '" + file + "'");
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,6 +23,7 @@ import java.io.InputStreamReader; ...@@ -23,6 +23,7 @@ import java.io.InputStreamReader;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Locale;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
...@@ -128,7 +129,8 @@ public class RunProcess { ...@@ -128,7 +129,8 @@ public class RunProcess {
// There's a bug in the Windows VM (https://bugs.openjdk.java.net/browse/JDK-8023130) // There's a bug in the Windows VM (https://bugs.openjdk.java.net/browse/JDK-8023130)
// that means we need to avoid inheritIO // that means we need to avoid inheritIO
private static boolean isInheritIOBroken() { 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; return false;
} }
String runtime = System.getProperty("java.runtime.version"); String runtime = System.getProperty("java.runtime.version");
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -27,6 +27,7 @@ import java.util.ArrayList; ...@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.jar.Manifest; import java.util.jar.Manifest;
...@@ -489,7 +490,7 @@ public class PropertiesLauncher extends Launcher { ...@@ -489,7 +490,7 @@ public class PropertiesLauncher extends Launcher {
} }
private Archive getArchive(File file) throws IOException { 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")) { if (name.endsWith(".jar") || name.endsWith(".zip")) {
return new JarFileArchive(file); return new JarFileArchive(file);
} }
...@@ -566,7 +567,8 @@ public class PropertiesLauncher extends Launcher { ...@@ -566,7 +567,8 @@ public class PropertiesLauncher extends Launcher {
if (path.startsWith("./")) { if (path.startsWith("./")) {
path = path.substring(2); 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; return path;
} }
if (path.endsWith("/*")) { if (path.endsWith("/*")) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.loader.util; package org.springframework.boot.loader.util;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
...@@ -188,7 +189,8 @@ public abstract class SystemPropertyUtils { ...@@ -188,7 +189,8 @@ public abstract class SystemPropertyUtils {
} }
if (propVal == null) { if (propVal == null) {
// Try uppercase with underscores as well. // Try uppercase with underscores as well.
propVal = System.getenv(key.toUpperCase().replace('.', '_')); propVal = System.getenv(key.toUpperCase(Locale.ENGLISH)
.replace('.', '_'));
} }
if (propVal != null) { if (propVal != null) {
return propVal; return propVal;
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.ansi; package org.springframework.boot.ansi;
import java.util.Locale;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
...@@ -35,7 +37,7 @@ public abstract class AnsiOutput { ...@@ -35,7 +37,7 @@ public abstract class AnsiOutput {
private static Boolean ansiCapable; private static Boolean ansiCapable;
private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name") private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name")
.toLowerCase(); .toLowerCase(Locale.ENGLISH);
private static final String ENCODE_START = "\033["; private static final String ENCODE_START = "\033[";
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package org.springframework.boot.bind; ...@@ -18,6 +18,7 @@ package org.springframework.boot.bind;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -184,7 +185,7 @@ public class PropertySourcesPropertyValues implements PropertyValues { ...@@ -184,7 +185,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
// Probably could not convert to Object, weird, but ignorable // Probably could not convert to Object, weird, but ignorable
} }
if (value == null) { if (value == null) {
value = source.getProperty(propertyName.toUpperCase()); value = source.getProperty(propertyName.toUpperCase(Locale.ENGLISH));
} }
putIfAbsent(propertyName, value, source); putIfAbsent(propertyName, value, source);
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.bind; package org.springframework.boot.bind;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.ConversionFailedException;
...@@ -127,7 +128,8 @@ class RelaxedConversionService implements ConversionService { ...@@ -127,7 +128,8 @@ class RelaxedConversionService implements ConversionService {
source = source.trim(); source = source.trim();
for (T candidate : (Set<T>) EnumSet.allOf(this.enumType)) { for (T candidate : (Set<T>) EnumSet.allOf(this.enumType)) {
RelaxedNames names = new RelaxedNames( RelaxedNames names = new RelaxedNames(
candidate.name().replace('_', '-').toLowerCase()); candidate.name().replace('_', '-')
.toLowerCase(Locale.ENGLISH));
for (String name : names) { for (String name : names) {
if (name.equals(source)) { if (name.equals(source)) {
return candidate; return candidate;
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package org.springframework.boot.bind; ...@@ -18,6 +18,7 @@ package org.springframework.boot.bind;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -91,7 +92,7 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -91,7 +92,7 @@ public final class RelaxedNames implements Iterable<String> {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value.isEmpty() ? value : value.toLowerCase(); return value.isEmpty() ? value : value.toLowerCase(Locale.ENGLISH);
} }
}, },
...@@ -100,7 +101,7 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -100,7 +101,7 @@ public final class RelaxedNames implements Iterable<String> {
@Override @Override
public String apply(String value) { public String apply(String value) {
return value.isEmpty() ? value : value.toUpperCase(); return value.isEmpty() ? value : value.toUpperCase(Locale.ENGLISH);
} }
}; };
...@@ -225,7 +226,7 @@ public final class RelaxedNames implements Iterable<String> { ...@@ -225,7 +226,7 @@ public final class RelaxedNames implements Iterable<String> {
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (String field : SEPARATED_TO_CAMEL_CASE_PATTERN.split(value)) { for (String field : SEPARATED_TO_CAMEL_CASE_PATTERN.split(value)) {
field = (caseInsensitive ? field.toLowerCase() : field); field = (caseInsensitive ? field.toLowerCase(Locale.ENGLISH) : field);
builder.append( builder.append(
builder.length() == 0 ? field : StringUtils.capitalize(field)); builder.length() == 0 ? field : StringUtils.capitalize(field));
} }
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.context.config; package org.springframework.boot.context.config;
import java.util.Locale;
import org.springframework.boot.ansi.AnsiOutput; import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.boot.ansi.AnsiOutput.Enabled; import org.springframework.boot.ansi.AnsiOutput.Enabled;
import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.bind.RelaxedPropertyResolver;
...@@ -40,7 +42,8 @@ public class AnsiOutputApplicationListener ...@@ -40,7 +42,8 @@ public class AnsiOutputApplicationListener
event.getEnvironment(), "spring.output.ansi."); event.getEnvironment(), "spring.output.ansi.");
if (resolver.containsProperty("enabled")) { if (resolver.containsProperty("enabled")) {
String enabled = resolver.getProperty("enabled"); String enabled = resolver.getProperty("enabled");
AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase())); AnsiOutput.setEnabled(Enum.valueOf(Enabled.class,
enabled.toUpperCase(Locale.ENGLISH)));
} }
if (resolver.containsProperty("console-available")) { if (resolver.containsProperty("console-available")) {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,6 +26,7 @@ import java.security.CodeSource; ...@@ -26,6 +26,7 @@ import java.security.CodeSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
...@@ -177,7 +178,7 @@ public abstract class AbstractEmbeddedServletContainerFactory ...@@ -177,7 +178,7 @@ public abstract class AbstractEmbeddedServletContainerFactory
this.logger.debug("Code archive: " + file); this.logger.debug("Code archive: " + file);
} }
if (file != null && file.exists() && !file.isDirectory() if (file != null && file.exists() && !file.isDirectory()
&& file.getName().toLowerCase().endsWith(extension)) { && file.getName().toLowerCase(Locale.ENGLISH).endsWith(extension)) {
return file.getAbsoluteFile(); return file.getAbsoluteFile();
} }
return null; return null;
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,6 +20,7 @@ import java.io.IOException; ...@@ -20,6 +20,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
...@@ -144,9 +145,9 @@ public class PropertySourcesLoader { ...@@ -144,9 +145,9 @@ public class PropertySourcesLoader {
} }
private boolean canLoadFileExtension(PropertySourceLoader loader, Resource resource) { private boolean canLoadFileExtension(PropertySourceLoader loader, Resource resource) {
String filename = resource.getFilename().toLowerCase(); String filename = resource.getFilename().toLowerCase(Locale.ENGLISH);
for (String extension : loader.getFileExtensions()) { for (String extension : loader.getFileExtensions()) {
if (filename.endsWith("." + extension.toLowerCase())) { if (filename.endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
return true; return true;
} }
} }
......
...@@ -19,6 +19,7 @@ package org.springframework.boot.jdbc; ...@@ -19,6 +19,7 @@ package org.springframework.boot.jdbc;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Locale;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -133,7 +134,7 @@ public enum DatabaseDriver { ...@@ -133,7 +134,7 @@ public enum DatabaseDriver {
@Override @Override
protected boolean matchProductName(String productName) { protected boolean matchProductName(String productName) {
return super.matchProductName(productName) return super.matchProductName(productName)
|| productName.toLowerCase().startsWith("firebird"); || productName.toLowerCase(Locale.ENGLISH).startsWith("firebird");
} }
}, },
...@@ -146,7 +147,7 @@ public enum DatabaseDriver { ...@@ -146,7 +147,7 @@ public enum DatabaseDriver {
@Override @Override
protected boolean matchProductName(String productName) { protected boolean matchProductName(String productName) {
return super.matchProductName(productName) return super.matchProductName(productName)
|| productName.toLowerCase().startsWith("db2/"); || productName.toLowerCase(Locale.ENGLISH).startsWith("db2/");
} }
}, },
...@@ -170,7 +171,7 @@ public enum DatabaseDriver { ...@@ -170,7 +171,7 @@ public enum DatabaseDriver {
@Override @Override
protected boolean matchProductName(String productName) { protected boolean matchProductName(String productName) {
return super.matchProductName(productName) return super.matchProductName(productName)
|| productName.toLowerCase().contains("as/400"); || productName.toLowerCase(Locale.ENGLISH).contains("as/400");
} }
}, },
...@@ -222,7 +223,7 @@ public enum DatabaseDriver { ...@@ -222,7 +223,7 @@ public enum DatabaseDriver {
* @return the identifier * @return the identifier
*/ */
public String getId() { public String getId() {
return name().toLowerCase(); return name().toLowerCase(Locale.ENGLISH);
} }
protected boolean matchProductName(String productName) { protected boolean matchProductName(String productName) {
...@@ -230,7 +231,7 @@ public enum DatabaseDriver { ...@@ -230,7 +231,7 @@ public enum DatabaseDriver {
} }
protected Collection<String> getUrlPrefixes() { 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 { ...@@ -265,7 +266,8 @@ public enum DatabaseDriver {
public static DatabaseDriver fromJdbcUrl(String url) { public static DatabaseDriver fromJdbcUrl(String url) {
if (StringUtils.hasLength(url)) { if (StringUtils.hasLength(url)) {
Assert.isTrue(url.startsWith("jdbc"), "URL must start with 'jdbc'"); 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 (DatabaseDriver driver : values()) {
for (String urlPrefix : driver.getUrlPrefixes()) { for (String urlPrefix : driver.getUrlPrefixes()) {
String prefix = ":" + urlPrefix + ":"; String prefix = ":" + urlPrefix + ":";
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.logging; package org.springframework.boot.logging;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
...@@ -370,7 +371,7 @@ public class LoggingApplicationListener implements GenericApplicationListener { ...@@ -370,7 +371,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
if ("false".equalsIgnoreCase(level)) { if ("false".equalsIgnoreCase(level)) {
return LogLevel.OFF; return LogLevel.OFF;
} }
return LogLevel.valueOf(level.toUpperCase()); return LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH));
} }
private void registerShutdownHookIfNecessary(Environment environment, private void registerShutdownHookIfNecessary(Environment environment,
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -21,6 +21,7 @@ import java.io.IOException; ...@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
...@@ -250,7 +251,8 @@ public class ApplicationPidFileWriter ...@@ -250,7 +251,8 @@ public class ApplicationPidFileWriter
private final String[] properties; private final String[] properties;
SystemProperty(String name) { SystemProperty(String name) {
this.properties = new String[] { name.toUpperCase(), name.toLowerCase() }; this.properties = new String[] { name.toUpperCase(Locale.ENGLISH),
name.toLowerCase(Locale.ENGLISH) };
} }
@Override @Override
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.system; package org.springframework.boot.system;
import java.io.File; import java.io.File;
import java.util.Locale;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
...@@ -113,10 +114,10 @@ public class EmbeddedServerPortFileWriter ...@@ -113,10 +114,10 @@ public class EmbeddedServerPortFileWriter
String extension = StringUtils.getFilenameExtension(this.file.getName()); String extension = StringUtils.getFilenameExtension(this.file.getName());
name = name.substring(0, name.length() - extension.length() - 1); name = name.substring(0, name.length() - extension.length() - 1);
if (isUpperCase(name)) { if (isUpperCase(name)) {
name = name + "-" + contextName.toUpperCase(); name = name + "-" + contextName.toUpperCase(Locale.ENGLISH);
} }
else { else {
name = name + "-" + contextName.toLowerCase(); name = name + "-" + contextName.toLowerCase(Locale.ENGLISH);
} }
if (StringUtils.hasLength(extension)) { if (StringUtils.hasLength(extension)) {
name = name + "." + extension; name = name + "." + extension;
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.boot.web.servlet; package org.springframework.boot.web.servlet;
import java.util.Locale;
import javax.servlet.MultipartConfigElement; import javax.servlet.MultipartConfigElement;
import org.springframework.util.Assert; import org.springframework.util.Assert;
...@@ -110,7 +112,7 @@ public class MultipartConfigFactory { ...@@ -110,7 +112,7 @@ public class MultipartConfigFactory {
private long parseSize(String size) { private long parseSize(String size) {
Assert.hasLength(size, "Size must not be empty"); Assert.hasLength(size, "Size must not be empty");
size = size.toUpperCase(); size = size.toUpperCase(Locale.ENGLISH);
if (size.endsWith("KB")) { if (size.endsWith("KB")) {
return Long.valueOf(size.substring(0, size.length() - 2)) * 1024; return Long.valueOf(size.substring(0, size.length() - 2)) * 1024;
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,6 +19,7 @@ package org.springframework.boot.system; ...@@ -19,6 +19,7 @@ package org.springframework.boot.system;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import org.junit.After; import org.junit.After;
...@@ -103,7 +104,7 @@ public class EmbeddedServerPortFileWriterTests { ...@@ -103,7 +104,7 @@ public class EmbeddedServerPortFileWriterTests {
@Test @Test
public void createUpperCaseManagementPortFile() throws Exception { public void createUpperCaseManagementPortFile() throws Exception {
File file = this.temporaryFolder.newFile(); File file = this.temporaryFolder.newFile();
file = new File(file.getParentFile(), file.getName().toUpperCase()); file = new File(file.getParentFile(), file.getName().toUpperCase(Locale.ENGLISH));
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file); EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("management", 9090)); listener.onApplicationEvent(mockEvent("management", 9090));
String managementFile = file.getName(); String managementFile = file.getName();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment