From 79233b019e5dccd415c39a9ad803c7df11964aaa Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 25 Jan 2017 10:41:47 +0100 Subject: [PATCH 1/5] Fix keys format for embedded mongodb support Closes gh-8102 --- .../src/main/asciidoc/appendix-application-properties.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 4a273a33f8..1c6aeac176 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -805,9 +805,9 @@ content into your application; rather pick only the properties that you need. # EMBEDDED MONGODB ({sc-spring-boot-autoconfigure}/mongo/embedded/EmbeddedMongoProperties.{sc-ext}[EmbeddedMongoProperties]) spring.mongodb.embedded.features=SYNC_DELAY # Comma-separated list of features to enable. - spring.mongodb.embedded.storage.databaseDir= # Directory used for data storage. - spring.mongodb.embedded.storage.oplogSize= # Maximum size of the oplog in megabytes. - spring.mongodb.embedded.storage.replSetName= # Name of the replica set. + spring.mongodb.embedded.storage.database-dir= # Directory used for data storage. + spring.mongodb.embedded.storage.oplog-size= # Maximum size of the oplog in megabytes. + spring.mongodb.embedded.storage.repl-set-name= # Name of the replica set. spring.mongodb.embedded.version=2.6.10 # Version of Mongo to use. # REDIS ({sc-spring-boot-autoconfigure}/data/redis/RedisProperties.{sc-ext}[RedisProperties]) From 32f9e90de578381dc025da40ad9b1f4943e5cd15 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 25 Jan 2017 09:50:31 +0900 Subject: [PATCH 2/5] Replace 'String.length() == 0' with 'String.isEmpty()' See gh-8103 --- .../endpoint/ConfigurationPropertiesReportEndpoint.java | 2 +- .../boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java | 2 +- .../boot/autoconfigure/amqp/RabbitProperties.java | 2 +- .../boot/autoconfigure/h2/H2ConsoleProperties.java | 2 +- .../boot/autoconfigure/webservices/WebServicesProperties.java | 2 +- .../java/org/springframework/boot/loader/jar/AsciiBytes.java | 2 +- .../org/springframework/boot/loader/jar/JarURLConnection.java | 4 ++-- .../springframework/boot/bind/RelaxedConversionService.java | 2 +- .../ConfigurationWarningsApplicationContextInitializer.java | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java index 958bfcce5f..7491cfe416 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java @@ -234,7 +234,7 @@ public class ConfigurationPropertiesReportEndpoint private Map sanitize(String prefix, Map map) { for (Map.Entry entry : map.entrySet()) { String key = entry.getKey(); - String qualifiedKey = (prefix.length() == 0 ? prefix : prefix + ".") + key; + String qualifiedKey = (prefix.isEmpty() ? prefix : prefix + ".") + key; Object value = entry.getValue(); if (value instanceof Map) { map.put(key, sanitize(qualifiedKey, (Map) value)); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java index 110445c843..dfee586dee 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java @@ -69,7 +69,7 @@ public abstract class AbstractMvcEndpoint extends WebMvcConfigurerAdapter @PostConstruct private void validate() { Assert.notNull(this.path, "Path must not be null"); - Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"), + Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"), "Path must start with / or be empty"); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 929b6afadb..c4bdc5d582 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -770,7 +770,7 @@ public class RabbitProperties { int hostIndex = input.indexOf("/"); if (hostIndex >= 0) { this.virtualHost = input.substring(hostIndex + 1); - if (this.virtualHost.length() == 0) { + if (this.virtualHost.isEmpty()) { this.virtualHost = "/"; } input = input.substring(0, hostIndex); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java index 6bc37a86cc..dcc931e593 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java @@ -47,7 +47,7 @@ public class H2ConsoleProperties { @PostConstruct private void validate() { Assert.notNull(this.path, "Path must not be null"); - Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"), + Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"), "Path must start with / or be empty"); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java index 3d6d73a188..87a57a2cfa 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java @@ -44,7 +44,7 @@ public class WebServicesProperties { @PostConstruct private void validate() { Assert.notNull(this.path, "Path must not be null"); - Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"), + Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"), "Path must start with / or be empty"); } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java index 333d7775f3..d6b2ab42b2 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java @@ -121,7 +121,7 @@ final class AsciiBytes { } public AsciiBytes append(String string) { - if (string == null || string.length() == 0) { + if (string == null || string.isEmpty()) { return this; } return append(string.getBytes(UTF_8)); diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 7f2b5ce6ed..589e5b23ff 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -293,7 +293,7 @@ final class JarURLConnection extends java.net.JarURLConnection { } private String decode(String source) { - if (source.length() == 0 || (source.indexOf('%') < 0)) { + if (source.isEmpty() || (source.indexOf('%') < 0)) { return source; } ByteArrayOutputStream bos = new ByteArrayOutputStream(source.length()); @@ -347,7 +347,7 @@ final class JarURLConnection extends java.net.JarURLConnection { } public boolean isEmpty() { - return this.name.length() == 0; + return this.name.isEmpty(); } public String getContentType() { diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java index affdec0d1e..67c511ae5b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java @@ -120,7 +120,7 @@ class RelaxedConversionService implements ConversionService { @Override public T convert(String source) { - if (source.length() == 0) { + if (source.isEmpty()) { // It's an empty enum identifier: reset the enum value to null. return null; } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java b/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java index bc61b1f561..aa7ba3de1a 100755 --- a/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java @@ -206,14 +206,14 @@ public class ConfigurationWarningsApplicationContextInitializer } private boolean isProblematicPackage(String scannedPackage) { - if (scannedPackage == null || scannedPackage.length() == 0) { + if (scannedPackage == null || scannedPackage.isEmpty()) { return true; } return PROBLEM_PACKAGES.contains(scannedPackage); } private String getDisplayName(String scannedPackage) { - if (scannedPackage == null || scannedPackage.length() == 0) { + if (scannedPackage == null || scannedPackage.isEmpty()) { return "the default package"; } return "'" + scannedPackage + "'"; From 551bfb2c604df480ba963a4c266c24910d090f29 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 25 Jan 2017 10:51:48 +0100 Subject: [PATCH 3/5] Polish contribution Closes gh-8103 --- .../actuate/endpoint/ConfigurationPropertiesReportEndpoint.java | 2 +- .../boot/autoconfigure/amqp/RabbitProperties.java | 2 +- .../org/springframework/boot/loader/jar/JarURLConnection.java | 2 +- .../org/springframework/boot/bind/RelaxedConversionService.java | 2 +- .../ConfigurationWarningsApplicationContextInitializer.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java index 7491cfe416..8811ceab7f 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index c4bdc5d582..8b0ca0d794 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 589e5b23ff..8199fb4490 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java index 67c511ae5b..399d9672de 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java b/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java index aa7ba3de1a..203ff05083 100755 --- a/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. From d58f38f6f646ae0a7a15845dea041b797244c57e Mon Sep 17 00:00:00 2001 From: dreis Date: Tue, 24 Jan 2017 19:39:17 +0100 Subject: [PATCH 4/5] Use String.replace() with single char if possible See gh-8089 --- .../boot/actuate/endpoint/mvc/HealthMvcEndpoint.java | 2 +- .../boot/autoconfigure/cache/CacheCondition.java | 2 +- .../boot/autoconfigure/session/SessionCondition.java | 2 +- .../autoconfigure/web/DefaultErrorViewResolverTests.java | 2 +- .../boot/cli/command/archive/ArchiveCommand.java | 2 +- .../boot/cli/compiler/ExtendedGroovyClassLoader.java | 2 +- .../restart/classloader/RestartClassLoaderTests.java | 2 +- .../boot/devtools/settings/DevToolsSettingsTests.java | 2 +- .../springframework/boot/junit/compiler/TestCompiler.java | 2 +- .../boot/test/testutil/AbstractConfigurationClassTests.java | 2 +- .../springframework/boot/loader/tools/MainClassFinder.java | 2 +- .../org/springframework/boot/loader/tools/TestJarFile.java | 2 +- .../springframework/boot/loader/LaunchedURLClassLoader.java | 4 ++-- .../org/springframework/boot/loader/PropertiesLauncher.java | 2 +- .../boot/loader/util/SystemPropertyUtils.java | 4 ++-- .../springframework/boot/bind/RelaxedConversionService.java | 2 +- .../java/org/springframework/boot/bind/RelaxedNames.java | 6 +++--- .../springframework/boot/logging/AbstractLoggingSystem.java | 2 +- .../embedded/XmlEmbeddedWebApplicationContextTests.java | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java index ab2d42aff6..ada10fec51 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java @@ -139,7 +139,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter createClass(byte[] code, ClassNode classNode) { Class createdClass = super.createClass(code, classNode); ExtendedGroovyClassLoader.this.classResources - .put(classNode.getName().replace(".", "/") + ".class", code); + .put(classNode.getName().replace('.', '/') + ".class", code); return createdClass; } diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java index f82d773912..09438e4539 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java @@ -52,7 +52,7 @@ public class RestartClassLoaderTests { private static final String PACKAGE = RestartClassLoaderTests.class.getPackage() .getName(); - private static final String PACKAGE_PATH = PACKAGE.replace(".", "/"); + private static final String PACKAGE_PATH = PACKAGE.replace('.', '/'); private static final Charset UTF_8 = Charset.forName("UTF-8"); diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java index 121c911e41..84594c6797 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java @@ -37,7 +37,7 @@ public class DevToolsSettingsTests { public TemporaryFolder temporaryFolder = new TemporaryFolder(); private static final String ROOT = DevToolsSettingsTests.class.getPackage().getName() - .replace(".", "/") + "/"; + .replace('.', '/') + "/"; @Test public void includePatterns() throws Exception { diff --git a/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java b/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java index 53328c7a96..5e3883d94c 100644 --- a/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java +++ b/spring-boot-test-support/src/main/java/org/springframework/boot/junit/compiler/TestCompiler.java @@ -99,7 +99,7 @@ public class TestCompiler { } public static String sourcePathFor(Class type) { - return type.getName().replace(".", "/") + ".java"; + return type.getName().replace('.', '/') + ".java"; } protected File getSourceFolder() { diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java index ac70525042..b296d5fd20 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java @@ -65,7 +65,7 @@ public abstract class AbstractConfigurationClassTests { private Set findConfigurationClasses() throws IOException { Set configurationClasses = new HashSet(); Resource[] resources = this.resolver.getResources("classpath*:" - + getClass().getPackage().getName().replace(".", "/") + "/**/*.class"); + + getClass().getPackage().getName().replace('.', '/') + "/**/*.class"); for (Resource resource : resources) { if (!isTestClass(resource)) { MetadataReader metadataReader = new SimpleMetadataReaderFactory() diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index cc2fee07d1..639755f62e 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -262,7 +262,7 @@ public abstract class MainClassFinder { } private static String convertToClassName(String name, String prefix) { - name = name.replace("/", "."); + name = name.replace('/', '.'); name = name.replace('\\', '.'); name = name.substring(0, name.length() - DOT_CLASS.length()); if (prefix != null) { diff --git a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java index ee94dc2910..a9e813bf81 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java @@ -55,7 +55,7 @@ public class TestJarFile { File file = getFilePath(filename); file.getParentFile().mkdirs(); InputStream inputStream = getClass().getResourceAsStream( - "/" + classToCopy.getName().replace(".", "/") + ".class"); + "/" + classToCopy.getName().replace('.', '/') + ".class"); copyToFile(inputStream, file); if (time != null) { file.setLastModified(time); diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java index f3a3b22927..e252062ab5 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java @@ -132,8 +132,8 @@ public class LaunchedURLClassLoader extends URLClassLoader { AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override public Object run() throws ClassNotFoundException { - String packageEntryName = packageName.replace(".", "/") + "/"; - String classEntryName = className.replace(".", "/") + ".class"; + String packageEntryName = packageName.replace('.', '/') + "/"; + String classEntryName = className.replace('.', '/') + ".class"; for (URL url : getURLs()) { try { URLConnection connection = url.openConnection(); diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index a32f363806..194f5e7feb 100755 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -359,7 +359,7 @@ public class PropertiesLauncher extends Launcher { private String getProperty(String propertyKey, String manifestKey) throws Exception { if (manifestKey == null) { - manifestKey = propertyKey.replace(".", "-"); + manifestKey = propertyKey.replace('.', '-'); manifestKey = toCamelCase(manifestKey); } String property = SystemPropertyUtils.getProperty(propertyKey); diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java index 6f5097869f..4910ef8212 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java @@ -184,11 +184,11 @@ public abstract class SystemPropertyUtils { } if (propVal == null) { // Try with underscores. - propVal = System.getenv(key.replace(".", "_")); + propVal = System.getenv(key.replace('.', '_')); } if (propVal == null) { // Try uppercase with underscores as well. - propVal = System.getenv(key.toUpperCase().replace(".", "_")); + propVal = System.getenv(key.toUpperCase().replace('.', '_')); } if (propVal != null) { return propVal; diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java index 399d9672de..5db206cc57 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java @@ -127,7 +127,7 @@ class RelaxedConversionService implements ConversionService { source = source.trim(); for (T candidate : (Set) EnumSet.allOf(this.enumType)) { RelaxedNames names = new RelaxedNames( - candidate.name().replace("_", "-").toLowerCase()); + candidate.name().replace('_', '-').toLowerCase()); for (String name : names) { if (name.equals(source)) { return candidate; diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java index ace258a498..07f793c5b8 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java @@ -127,7 +127,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.indexOf('-') != -1 ? value.replace("-", "_") : value; + return value.indexOf('-') != -1 ? value.replace('-', '_') : value; } }, @@ -136,7 +136,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.indexOf('_') != -1 ? value.replace("_", ".") : value; + return value.indexOf('_') != -1 ? value.replace('_', '.') : value; } }, @@ -145,7 +145,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.indexOf('.') != -1 ? value.replace(".", "_") : value; + return value.indexOf('.') != -1 ? value.replace('.', '_') : value; } }, diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 376c13ef99..6f2530daa1 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -172,7 +172,7 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { protected final String getPackagedConfigFile(String fileName) { String defaultPath = ClassUtils.getPackageName(getClass()); - defaultPath = defaultPath.replace(".", "/"); + defaultPath = defaultPath.replace('.', '/'); defaultPath = defaultPath + "/" + fileName; defaultPath = "classpath:" + defaultPath; return defaultPath; diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java index 6b29d48077..9486936ce6 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.verify; public class XmlEmbeddedWebApplicationContextTests { private static final String PATH = XmlEmbeddedWebApplicationContextTests.class - .getPackage().getName().replace(".", "/") + "/"; + .getPackage().getName().replace('.', '/') + "/"; private static final String FILE = "exampleEmbeddedWebApplicationConfiguration.xml"; From 505e7f75eacf14b2443b9a45a62098711d243fcb Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 25 Jan 2017 10:59:26 +0100 Subject: [PATCH 5/5] Polish contribution Closes gh-8089 --- .../boot/autoconfigure/cache/CacheCondition.java | 2 +- .../boot/autoconfigure/web/DefaultErrorViewResolverTests.java | 2 +- .../boot/cli/command/archive/ArchiveCommand.java | 2 +- .../boot/cli/compiler/ExtendedGroovyClassLoader.java | 2 +- .../devtools/restart/classloader/RestartClassLoaderTests.java | 2 +- .../boot/devtools/settings/DevToolsSettingsTests.java | 2 +- .../boot/test/testutil/AbstractConfigurationClassTests.java | 2 +- .../org/springframework/boot/loader/tools/MainClassFinder.java | 2 +- .../java/org/springframework/boot/loader/tools/TestJarFile.java | 2 +- .../org/springframework/boot/loader/LaunchedURLClassLoader.java | 2 +- .../org/springframework/boot/loader/PropertiesLauncher.java | 2 +- .../springframework/boot/loader/util/SystemPropertyUtils.java | 2 +- .../org/springframework/boot/logging/AbstractLoggingSystem.java | 2 +- .../context/embedded/XmlEmbeddedWebApplicationContextTests.java | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheCondition.java index 504e394253..a114ce1e14 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DefaultErrorViewResolverTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DefaultErrorViewResolverTests.java index 67f81c5b21..f059f82ac5 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DefaultErrorViewResolverTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DefaultErrorViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java index 00c7ca2b5f..be7086f776 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java index 0e2950c321..9992ba9c6d 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java index 09438e4539..1ad2954ac4 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java index 84594c6797..0c65b5ac8a 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/settings/DevToolsSettingsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java index b296d5fd20..189f52727a 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/testutil/AbstractConfigurationClassTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index 639755f62e..f46257618f 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java index a9e813bf81..22d148d5e6 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java index e252062ab5..135d8b4671 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 194f5e7feb..ca6ca8ce1f 100755 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java index 4910ef8212..2bbfa8bf0f 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 6f2530daa1..bb6d40e8e6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java index 9486936ce6..94ae430a18 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/XmlEmbeddedWebApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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.