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:
Stephane Nicoll
2018-02-26 17:49:03 +01:00
parent 915eaf3447
commit b4a7e1d64b
38 changed files with 148 additions and 87 deletions

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.autoconfigure.cache;
import java.util.Locale;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
@@ -50,7 +52,8 @@ class CacheCondition extends SpringBootCondition {
}
CacheType cacheType = CacheConfigurations
.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())) {
return ConditionOutcome.match(message.because(value + " cache type"));
}

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.
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import org.springframework.beans.factory.BeanFactory;
@@ -399,7 +400,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

@@ -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.autoconfigure.data.cassandra;
import java.util.List;
import java.util.Locale;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
@@ -114,7 +115,8 @@ public class CassandraDataAutoConfiguration {
session.setKeyspaceName(this.properties.getKeyspaceName());
String name = this.propertyResolver.getProperty("schemaAction",
SchemaAction.NONE.name());
SchemaAction schemaAction = SchemaAction.valueOf(name.toUpperCase());
SchemaAction schemaAction = SchemaAction.valueOf(
name.toUpperCase(Locale.ENGLISH));
session.setSchemaAction(schemaAction);
return session;
}

View 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.
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Locale;
import javax.sql.DataSource;
@@ -173,7 +174,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

@@ -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.autoconfigure.session;
import java.util.Locale;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.ObjectProvider;
@@ -100,7 +102,8 @@ public class SessionAutoConfiguration {
if (storeType != null) {
throw new IllegalArgumentException("No session repository could be "
+ "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 "
+ "configured: set the 'spring.session.store-type' property");

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.autoconfigure.session;
import java.util.Locale;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
@@ -45,7 +47,8 @@ class SessionCondition extends SpringBootCondition {
return ConditionOutcome.noMatch(
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())) {
return ConditionOutcome.match(message
.found("spring.session.store-type property").items(sessionStoreType));

View 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.
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.web;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -78,7 +79,7 @@ public abstract class AbstractErrorController implements ErrorController {
if (parameter == null) {
return false;
}
return !"false".equals(parameter.toLowerCase());
return !"false".equals(parameter.toLowerCase(Locale.ENGLISH));
}
protected HttpStatus getStatus(HttpServletRequest request) {