diff --git a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java index 14d8a267aed9..bad6038f3b9a 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java @@ -89,7 +89,7 @@ void checkArchitecture() throws IOException { if (!violations.isEmpty()) { StringBuilder report = new StringBuilder(); for (EvaluationResult violation : violations) { - report.append(violation.getFailureReport().toString()); + report.append(violation.getFailureReport()); report.append(String.format("%n")); } Files.writeString(outputFile.toPath(), report.toString(), StandardOpenOption.CREATE, diff --git a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java index 8b6f834103f3..eaaadf3b9474 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java @@ -154,7 +154,7 @@ private Provider autoConfigurationImports(Project proj }); } - private static record AutoConfigurationImports(Path importsFile, List imports) { + private record AutoConfigurationImports(Path importsFile, List imports) { } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java index a18d10481d80..6cbd5ae787b5 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java @@ -221,7 +221,7 @@ private void addClassifiedManagedDependencies(Node dependencyManagement) { .collect(Collectors.toSet()); Node target = dependency; for (String classifier : classifiers) { - if (classifier.length() > 0) { + if (!classifier.isEmpty()) { if (target == null) { target = new Node(null, "dependency"); target.appendNode("groupId", groupId); diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java index 9a77ab8a58eb..fbd12f571f28 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java @@ -69,7 +69,7 @@ private URI normalize(URI uri) { if ("/".equals(uri.getPath())) { return uri; } - return URI.create(uri.toString() + "/"); + return URI.create(uri + "/"); } @Override diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java index 941a132b4e2d..bb5833d34591 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java @@ -125,7 +125,7 @@ static class TestPathMatcher implements PathMapper { @Override public String getRootPath(EndpointId endpointId) { if (endpointId.toString().endsWith("one")) { - return "1/" + endpointId.toString(); + return "1/" + endpointId; } return null; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index e7faed17b4cf..fa77c0dc6947 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -234,9 +234,8 @@ private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMa String extensionBeanNames = extensions.stream() .map(ExtensionBean::getBeanName) .collect(Collectors.joining(", ")); - throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates.toString() - + " to " + endpointBean.getBeanName() - + (extensions.isEmpty() ? "" : " (" + extensionBeanNames + ")")); + throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates + " to " + + endpointBean.getBeanName() + (extensions.isEmpty() ? "" : " (" + extensionBeanNames + ")")); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java index b15aa920591c..79445877bd62 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java @@ -127,7 +127,7 @@ private Object getContributor(String[] path, int pathOffset) { private String getName(String[] path, int pathOffset) { StringBuilder name = new StringBuilder(); while (pathOffset < path.length) { - name.append((name.length() != 0) ? "/" : ""); + name.append((!name.isEmpty()) ? "/" : ""); name.append(path[pathOffset]); pathOffset++; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index 1de90f0c917d..60f0f90cdd54 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -332,7 +332,7 @@ private String createOnBeanNoMatchReason(MatchResult matchResult) { private void appendMessageForNoMatches(StringBuilder reason, Collection unmatched, String description) { if (!unmatched.isEmpty()) { - if (reason.length() > 0) { + if (!reason.isEmpty()) { reason.append(" and "); } reason.append("did not find any beans "); @@ -347,7 +347,7 @@ private String createOnMissingBeanNoMatchReason(MatchResult matchResult) { appendMessageForMatches(reason, matchResult.getMatchedAnnotations(), "annotated with"); appendMessageForMatches(reason, matchResult.getMatchedTypes(), "of type"); if (!matchResult.getMatchedNames().isEmpty()) { - if (reason.length() > 0) { + if (!reason.isEmpty()) { reason.append(" and "); } reason.append("found beans named "); @@ -360,7 +360,7 @@ private void appendMessageForMatches(StringBuilder reason, Map { - if (reason.length() > 0) { + if (!reason.isEmpty()) { reason.append(" and "); } reason.append("found beans "); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java index 232df1adb94e..863656aca449 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java @@ -144,7 +144,7 @@ protected File getHomeDirectory() { } @SafeVarargs - private final File getHomeDirectory(Supplier... pathSuppliers) { + private File getHomeDirectory(Supplier... pathSuppliers) { for (Supplier pathSupplier : pathSuppliers) { String path = pathSupplier.get(); if (StringUtils.hasText(path)) { diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java index e7a6ac524faf..f48abdf052f2 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java @@ -23,6 +23,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -159,7 +160,7 @@ private static List getUrlsFromManifestClassPathAttribute(URL jarUrl, JarFi urls.add(referenced); } else { - referenced = new URL(jarUrl, URLDecoder.decode(entry, "UTF-8")); + referenced = new URL(jarUrl, URLDecoder.decode(entry, StandardCharsets.UTF_8)); if (new File(referenced.getFile()).exists()) { urls.add(referenced); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/AssertProviderApplicationContextInvocationHandler.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/AssertProviderApplicationContextInvocationHandler.java index 685fb117140f..c472c764d7b5 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/AssertProviderApplicationContextInvocationHandler.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/AssertProviderApplicationContextInvocationHandler.java @@ -153,7 +153,7 @@ private Object invokeApplicationContextMethod(Method method, Object[] args) thro private ApplicationContext getStartedApplicationContext() { if (this.startupFailure != null) { - throw new IllegalStateException(toString() + " failed to start", this.startupFailure); + throw new IllegalStateException(this + " failed to start", this.startupFailure); } return this.applicationContext; } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index 24e38b8ab503..7ec967c573de 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -956,7 +956,7 @@ private RequestEntity createRequestEntityWithRootAppliedUri(RequestEntity private URI applyRootUriIfNecessary(URI uri) { UriTemplateHandler uriTemplateHandler = this.restTemplate.getUriTemplateHandler(); if ((uriTemplateHandler instanceof RootUriTemplateHandler rootHandler) && uri.toString().startsWith("/")) { - return URI.create(rootHandler.getRootUri() + uri.toString()); + return URI.create(rootHandler.getRootUri() + uri); } return uri; } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java index 87f6d33ffa51..406ff1cc1c98 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java @@ -169,7 +169,7 @@ void parseMapShouldReturnContent() throws Exception { assertThat(tester.parse(MAP_JSON)).asMap().containsEntry("a", OBJECT); } - protected static final ExampleObject createExampleObject(String name, int age) { + protected static ExampleObject createExampleObject(String name, int age) { ExampleObject exampleObject = new ExampleObject(); exampleObject.setName(name); exampleObject.setAge(age); diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/web/SpringBootMockServletContextTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/web/SpringBootMockServletContextTests.java index c641e03f3f6e..0697f7d01987 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/web/SpringBootMockServletContextTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/web/SpringBootMockServletContextTests.java @@ -20,6 +20,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import jakarta.servlet.ServletContext; import org.junit.jupiter.api.Test; @@ -80,7 +81,7 @@ protected String getResourceLocation(String path) { }; URL resource = context.getResource("/"); assertThat(resource).isNotNull(); - File file = new File(URLDecoder.decode(resource.getPath(), "UTF-8")); + File file = new File(URLDecoder.decode(resource.getPath(), StandardCharsets.UTF_8)); assertThat(file).exists().isDirectory(); String[] contents = file.list((dir, name) -> !(".".equals(name) || "..".equals(name))); assertThat(contents).isNotNull(); diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java index b8d010f613df..9d20af2ac224 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java @@ -91,8 +91,7 @@ List> getSources() { * Relevant details from {@link ContainerConnectionSource} used as a * MergedContextConfiguration cache key. */ - private static record CacheKey(String connectionName, Set> connectionDetailsTypes, - Container container) { + private record CacheKey(String connectionName, Set> connectionDetailsTypes, Container container) { CacheKey(ContainerConnectionSource source) { this(source.getConnectionName(), source.getConnectionDetailsTypes(), source.getContainerSupplier().get()); diff --git a/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/ImportTestcontainersTests.java b/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/ImportTestcontainersTests.java index 542f350bf265..6b3ef4722fd5 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/ImportTestcontainersTests.java +++ b/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/ImportTestcontainersTests.java @@ -162,7 +162,7 @@ interface ContainerDefinitions { } @Retention(RetentionPolicy.RUNTIME) - static @interface ContainerAnnotation { + @interface ContainerAnnotation { } diff --git a/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java index 912975d1d018..723a4203f0b8 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java @@ -68,7 +68,7 @@ RedisContainer redisContainer(DynamicPropertyRegistry properties) { } @ConfigurationProperties("container") - static record ContainerProperties(int port) { + record ContainerProperties(int port) { } static class TestBean { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java index 2137997890a4..90099cbe8fed 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java @@ -345,7 +345,7 @@ private String toCommaDelimitedString(List list) { } StringBuilder result = new StringBuilder(); for (Object item : list) { - result.append((result.length() != 0) ? "," : ""); + result.append((!result.isEmpty()) ? "," : ""); result.append(item); } return result.toString(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java index 23d41637ab3a..29028b605850 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java @@ -173,7 +173,7 @@ public JSONStringer endObject() throws JSONException { * @throws JSONException if processing of json failed */ JSONStringer open(Scope empty, String openBracket) throws JSONException { - if (this.stack.isEmpty() && this.out.length() > 0) { + if (this.stack.isEmpty() && !this.out.isEmpty()) { throw new JSONException("Nesting problem: multiple top-level roots"); } beforeValue(); @@ -423,7 +423,7 @@ else if (context != Scope.NULL) { */ @Override public String toString() { - return this.out.length() == 0 ? null : this.out.toString(); + return this.out.isEmpty() ? null : this.out.toString(); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java index 315a281774ef..e00802384edd 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java @@ -65,7 +65,7 @@ private String buildName(String prefix, String name) { fullName.append(prefix); } if (name != null) { - if (fullName.length() > 0) { + if (!fullName.isEmpty()) { fullName.append('.'); } fullName.append(ConfigurationMetadata.toDashedCase(name)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/TestPrintStream.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/TestPrintStream.java index 109901b47734..f3d1beb43f84 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/TestPrintStream.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/TestPrintStream.java @@ -37,7 +37,7 @@ */ class TestPrintStream extends PrintStream implements AssertProvider { - private final Class testClass; + private final Class testClass; TestPrintStream(Object testInstance) { super(new ByteArrayOutputStream()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 3703ac136705..96702fe4b603 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -26,6 +26,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -227,7 +228,7 @@ private InputStream getResource(String config) throws Exception { private String handleUrl(String path) throws UnsupportedEncodingException { if (path.startsWith("jar:file:") || path.startsWith("file:")) { - path = URLDecoder.decode(path, "UTF-8"); + path = URLDecoder.decode(path, StandardCharsets.UTF_8); if (path.startsWith("file:")) { path = path.substring("file:".length()); if (path.startsWith("//")) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 859ae88ab000..0af645f19c7b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -20,12 +20,12 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.net.URLStreamHandler; +import java.nio.charset.StandardCharsets; import java.security.Permission; /** @@ -318,13 +318,8 @@ private void write(String source, ByteArrayOutputStream outputStream) { for (int i = 0; i < length; i++) { int c = source.charAt(i); if (c > 127) { - try { - String encoded = URLEncoder.encode(String.valueOf((char) c), "UTF-8"); - write(encoded, outputStream); - } - catch (UnsupportedEncodingException ex) { - throw new IllegalStateException(ex); - } + String encoded = URLEncoder.encode(String.valueOf((char) c), StandardCharsets.UTF_8); + write(encoded, outputStream); } else { if (c == '%') { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java index 9b6707794d09..8c6c9599ae3d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java @@ -227,7 +227,7 @@ public void report(Diagnostic diagnostic) { } boolean hasReportedErrors() { - return this.message.length() > 0; + return !this.message.isEmpty(); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 18a4009620ad..c4dfd77162af 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -342,7 +342,7 @@ private void addClasspath(List args) throws MojoExecutionException { try { StringBuilder classpath = new StringBuilder(); for (URL ele : getClassPathUrls()) { - if (classpath.length() > 0) { + if (!classpath.isEmpty()) { classpath.append(File.pathSeparator); } classpath.append(new File(ele.toURI())); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CommandLineBuilder.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CommandLineBuilder.java index 1fa132465083..d2a04dd6910d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CommandLineBuilder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CommandLineBuilder.java @@ -98,7 +98,7 @@ static class ClasspathBuilder { static String build(List classpathElements) { StringBuilder classpath = new StringBuilder(); for (URL element : classpathElements) { - if (classpath.length() > 0) { + if (!classpath.isEmpty()) { classpath.append(File.pathSeparator); } classpath.append(toFile(element)); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java index 98e4ac32a64a..8b6c5f3439f5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -118,7 +118,7 @@ private void appendContext(StringBuilder message) { } append(context, "started by ", () -> System.getProperty("user.name")); append(context, "in ", () -> System.getProperty("user.dir")); - if (context.length() > 0) { + if (!context.isEmpty()) { message.append(" ("); message.append(context); message.append(")"); @@ -140,7 +140,7 @@ private void append(StringBuilder message, String prefix, Callable call, value = defaultValue; } if (StringUtils.hasLength(value)) { - message.append((message.length() > 0) ? " " : ""); + message.append((!message.isEmpty()) ? " " : ""); message.append(prefix); message.append(value); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DataObjectPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DataObjectPropertyName.java index 041a439b2f91..d39cba0e4d56 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DataObjectPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DataObjectPropertyName.java @@ -52,7 +52,7 @@ public static String toDashedForm(String name) { } else { ch = (ch != '_') ? ch : '-'; - if (Character.isUpperCase(ch) && result.length() > 0 && result.charAt(result.length() - 1) != '-') { + if (Character.isUpperCase(ch) && !result.isEmpty() && result.charAt(result.length() - 1) != '-') { result.append('-'); } result.append(Character.toLowerCase(ch)); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java index 3f1eaf61f804..1329c7a043ac 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java @@ -211,7 +211,7 @@ private boolean isScalarValue(ConfigurationPropertySource source, ConfigurationP private String getKeyName(ConfigurationPropertyName name) { StringBuilder result = new StringBuilder(); for (int i = this.root.getNumberOfElements(); i < name.getNumberOfElements(); i++) { - if (result.length() != 0) { + if (!result.isEmpty()) { result.append('.'); } result.append(name.getElement(i, Form.ORIGINAL)); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 85a76d37263f..027f1b384b8b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -543,7 +543,7 @@ private String buildToString() { StringBuilder result = new StringBuilder(elements * 8); for (int i = 0; i < elements; i++) { boolean indexed = isIndexed(i); - if (result.length() > 0 && !indexed) { + if (!result.isEmpty() && !indexed) { result.append('.'); } if (indexed) { @@ -615,7 +615,7 @@ private static Elements elementsOf(CharSequence name, boolean returnNullIfInvali Assert.isTrue(returnNullIfInvalid, "Name must not be null"); return null; } - if (name.length() == 0) { + if (name.isEmpty()) { return Elements.EMPTY; } if (name.charAt(0) == '.' || name.charAt(name.length() - 1) == '.') { @@ -674,7 +674,7 @@ public static ConfigurationPropertyName adapt(CharSequence name, char separator) static ConfigurationPropertyName adapt(CharSequence name, char separator, Function elementValueProcessor) { Assert.notNull(name, "Name must not be null"); - if (name.length() == 0) { + if (name.isEmpty()) { return EMPTY; } Elements elements = new ElementsParser(name, separator).parse(elementValueProcessor); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java index f921bbca4baa..6218b42325f4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java @@ -57,7 +57,7 @@ private String convertName(ConfigurationPropertyName name) { private String convertName(ConfigurationPropertyName name, int numberOfElements) { StringBuilder result = new StringBuilder(); for (int i = 0; i < numberOfElements; i++) { - if (result.length() > 0) { + if (!result.isEmpty()) { result.append('_'); } result.append(name.getElement(i, Form.UNIFORM).toUpperCase(Locale.ENGLISH)); @@ -68,7 +68,7 @@ private String convertName(ConfigurationPropertyName name, int numberOfElements) private String convertLegacyName(ConfigurationPropertyName name) { StringBuilder result = new StringBuilder(); for (int i = 0; i < name.getNumberOfElements(); i++) { - if (result.length() > 0) { + if (!result.isEmpty()) { result.append('_'); } result.append(convertLegacyNameElement(name.getElement(i, Form.ORIGINAL))); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java index dad9038123b4..8737977f8707 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java @@ -158,7 +158,7 @@ else if (current == '\\') { } index++; } - if (build.length() > 0) { + if (!build.isEmpty()) { list.add(build.toString().trim()); } return list; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index 84bcedb40484..86abf0eb81b5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -130,7 +130,7 @@ public void format(LogEvent event, StringBuilder toAppendTo) { for (PatternFormatter formatter : this.formatters) { formatter.format(event, buf); } - if (buf.length() > 0) { + if (!buf.isEmpty()) { AnsiElement element = this.styling; if (element == null) { // Assume highlighting diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index e531e74ded60..009da77db768 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -260,14 +260,14 @@ private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) { List suppressedExceptions = new ArrayList<>(); for (Status status : loggerContext.getStatusManager().getCopyOfStatusList()) { if (status.getLevel() == Status.ERROR) { - errors.append((errors.length() > 0) ? String.format("%n") : ""); - errors.append(status.toString()); + errors.append((!errors.isEmpty()) ? String.format("%n") : ""); + errors.append(status); if (status.getThrowable() != null) { suppressedExceptions.add(status.getThrowable()); } } } - if (errors.length() == 0) { + if (errors.isEmpty()) { if (!StatusUtil.contextHasStatusListener(loggerContext)) { StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java index 0e7880d7a2ea..d41a39b576f5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java @@ -245,7 +245,7 @@ ConnectionFactory buildAndWrap(ConnectionFactoryOptions options) { private ConnectionFactoryOptions delegateFactoryOptions(ConnectionFactoryOptions options) { String protocol = toString(options.getRequiredValue(ConnectionFactoryOptions.PROTOCOL)); - if (protocol.trim().length() == 0) { + if (protocol.trim().isEmpty()) { throw new IllegalArgumentException(String.format("Protocol %s is not valid.", protocol)); } String[] protocols = protocol.split(COLON, 2); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java index a5f827bc7648..d5a9af25c6e0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java @@ -104,7 +104,7 @@ private void createParentDirectory(File file) { private void assertCanOverwrite(File file) throws IOException { if (!file.canWrite() || !canWritePosixFile(file)) { - throw new FileNotFoundException(file.toString() + " (permission denied)"); + throw new FileNotFoundException(file + " (permission denied)"); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index ae43901c8ad5..6c348987ca76 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.net.URL; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -553,7 +554,7 @@ public void removeResourceChangeListener(ResourceChangeListener listener) { private URLResource getMetaInfResource(URL resourceJar, String path) { try { - String urlPath = URLEncoder.encode(ENCODED_SLASH.matcher(path).replaceAll("/"), "UTF-8"); + String urlPath = URLEncoder.encode(ENCODED_SLASH.matcher(path).replaceAll("/"), StandardCharsets.UTF_8); URL resourceUrl = new URL(resourceJar + "META-INF/resources" + urlPath); URLResource resource = new URLResource(resourceUrl, path); if (resource.getContentLength() < 0) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java index b9c82a9b1275..940db092ec43 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java @@ -877,7 +877,7 @@ public ConfigData load(ConfigDataLoaderContext context, TestConfigDataResource r map.put("spring", "boot"); } String suffix = (!resource.isProfileSpecific()) ? "" : ":ps"; - map.put(resource.toString() + suffix, "true"); + map.put(resource + suffix, "true"); MapPropertySource propertySource = new MapPropertySource("loaded" + suffix, map); return new ConfigData(Collections.singleton(propertySource)); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index ee5b68be1656..15488c4fdb69 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -3091,7 +3091,7 @@ void setNested(NestedRecord nestedRecord) { } - static record NestedRecord(String name) { + record NestedRecord(String name) { } @EnableConfigurationProperties diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java index a782b9bbb80c..160773e52cef 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java @@ -207,7 +207,7 @@ static class OneConstructorWithoutAnnotations { } - static record OneConstructorOnRecord(String name, int age) { + record OneConstructorOnRecord(String name, int age) { } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/StaticResourceJarsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/StaticResourceJarsTests.java index 47d92ef8f225..49979592347b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/StaticResourceJarsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/StaticResourceJarsTests.java @@ -81,7 +81,7 @@ void uncPathsAreTolerated() throws Exception { void ignoreWildcardUrls() throws Exception { File jarFile = createResourcesJar("test-resources.jar"); URL folderUrl = jarFile.getParentFile().toURI().toURL(); - URL wildcardUrl = new URL(folderUrl.toString() + "*.jar"); + URL wildcardUrl = new URL(folderUrl + "*.jar"); List staticResourceJarUrls = new StaticResourceJars().getUrlsFrom(wildcardUrl); assertThat(staticResourceJarUrls).isEmpty(); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/Snake.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/Snake.java index a996c218dc5d..c0f20d6cfc08 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/Snake.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/Snake.java @@ -141,7 +141,7 @@ public String getLocationsJson() { sb.append(','); sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y))); } - return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb.toString()); + return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java index 2a8924fcbd44..348736bba507 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java @@ -77,7 +77,7 @@ public static void tick() throws Exception { sb.append(','); } } - broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); + broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb)); } public static void broadcast(String message) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeWebSocketHandler.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeWebSocketHandler.java index fbc37fc76141..2dd53f73a297 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeWebSocketHandler.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeWebSocketHandler.java @@ -74,7 +74,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio sb.append(','); } } - SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb.toString())); + SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb)); } @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/Snake.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/Snake.java index 0d9b5878b3fb..084e31646746 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/Snake.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/Snake.java @@ -141,7 +141,7 @@ public String getLocationsJson() { sb.append(','); sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y))); } - return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb.toString()); + return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java index 82be974569e3..69744e50d3ff 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java @@ -77,7 +77,7 @@ public static void tick() throws Exception { sb.append(','); } } - broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); + broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb)); } public static void broadcast(String message) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeWebSocketHandler.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeWebSocketHandler.java index b6131a1bdbd1..3d90901da014 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeWebSocketHandler.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeWebSocketHandler.java @@ -74,7 +74,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio sb.append(','); } } - SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb.toString())); + SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb)); } @Override diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Snake.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Snake.java index f996c36417cc..8b762b933ff2 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Snake.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Snake.java @@ -141,7 +141,7 @@ public String getLocationsJson() { sb.append(','); sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y))); } - return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb.toString()); + return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java index 1b044c018bee..8aa33a666904 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java @@ -77,7 +77,7 @@ public static void tick() throws Exception { sb.append(','); } } - broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString())); + broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb)); } public static void broadcast(String message) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java index e96e2c22e121..3a72279d6160 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java @@ -74,7 +74,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio sb.append(','); } } - SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb.toString())); + SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb)); } @Override