Skip to content

Commit 8599e5a

Browse files
quaffphilwebb
authored andcommitted
Remove unnecessary toString() calls
See gh-38739
1 parent b6e87ce commit 8599e5a

File tree

19 files changed

+30
-31
lines changed

19 files changed

+30
-31
lines changed

buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void checkArchitecture() throws IOException {
8989
if (!violations.isEmpty()) {
9090
StringBuilder report = new StringBuilder();
9191
for (EvaluationResult violation : violations) {
92-
report.append(violation.getFailureReport().toString());
92+
report.append(violation.getFailureReport());
9393
report.append(String.format("%n"));
9494
}
9595
Files.writeString(outputFile.toPath(), report.toString(), StandardOpenOption.CREATE,

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private URI normalize(URI uri) {
6969
if ("/".equals(uri.getPath())) {
7070
return uri;
7171
}
72-
return URI.create(uri.toString() + "/");
72+
return URI.create(uri + "/");
7373
}
7474

7575
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static class TestPathMatcher implements PathMapper {
125125
@Override
126126
public String getRootPath(EndpointId endpointId) {
127127
if (endpointId.toString().endsWith("one")) {
128-
return "1/" + endpointId.toString();
128+
return "1/" + endpointId;
129129
}
130130
return null;
131131
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,8 @@ private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMa
234234
String extensionBeanNames = extensions.stream()
235235
.map(ExtensionBean::getBeanName)
236236
.collect(Collectors.joining(", "));
237-
throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates.toString()
238-
+ " to " + endpointBean.getBeanName()
239-
+ (extensions.isEmpty() ? "" : " (" + extensionBeanNames + ")"));
237+
throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates + " to "
238+
+ endpointBean.getBeanName() + (extensions.isEmpty() ? "" : " (" + extensionBeanNames + ")"));
240239
}
241240
}
242241

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/AssertProviderApplicationContextInvocationHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private Object invokeApplicationContextMethod(Method method, Object[] args) thro
153153

154154
private ApplicationContext getStartedApplicationContext() {
155155
if (this.startupFailure != null) {
156-
throw new IllegalStateException(toString() + " failed to start", this.startupFailure);
156+
throw new IllegalStateException(this + " failed to start", this.startupFailure);
157157
}
158158
return this.applicationContext;
159159
}

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ private RequestEntity<?> createRequestEntityWithRootAppliedUri(RequestEntity<?>
956956
private URI applyRootUriIfNecessary(URI uri) {
957957
UriTemplateHandler uriTemplateHandler = this.restTemplate.getUriTemplateHandler();
958958
if ((uriTemplateHandler instanceof RootUriTemplateHandler rootHandler) && uri.toString().startsWith("/")) {
959-
return URI.create(rootHandler.getRootUri() + uri.toString());
959+
return URI.create(rootHandler.getRootUri() + uri);
960960
}
961961
return uri;
962962
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) {
259259
for (Status status : loggerContext.getStatusManager().getCopyOfStatusList()) {
260260
if (status.getLevel() == Status.ERROR) {
261261
errors.append((!errors.isEmpty()) ? String.format("%n") : "");
262-
errors.append(status.toString());
262+
errors.append(status);
263263
if (status.getThrowable() != null) {
264264
suppressedExceptions.add(status.getThrowable());
265265
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -104,7 +104,7 @@ private void createParentDirectory(File file) {
104104

105105
private void assertCanOverwrite(File file) throws IOException {
106106
if (!file.canWrite() || !canWritePosixFile(file)) {
107-
throw new FileNotFoundException(file.toString() + " (permission denied)");
107+
throw new FileNotFoundException(file + " (permission denied)");
108108
}
109109
}
110110

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ public ConfigData load(ConfigDataLoaderContext context, TestConfigDataResource r
877877
map.put("spring", "boot");
878878
}
879879
String suffix = (!resource.isProfileSpecific()) ? "" : ":ps";
880-
map.put(resource.toString() + suffix, "true");
880+
map.put(resource + suffix, "true");
881881
MapPropertySource propertySource = new MapPropertySource("loaded" + suffix, map);
882882
return new ConfigData(Collections.singleton(propertySource));
883883
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/StaticResourceJarsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void uncPathsAreTolerated() throws Exception {
8686
void ignoreWildcardUrls() throws Exception {
8787
File jarFile = createResourcesJar("test-resources.jar");
8888
URL folderUrl = jarFile.getParentFile().toURI().toURL();
89-
URL wildcardUrl = new URL(folderUrl.toString() + "*.jar");
89+
URL wildcardUrl = new URL(folderUrl + "*.jar");
9090
List<URL> staticResourceJarUrls = new StaticResourceJars().getUrlsFrom(wildcardUrl);
9191
assertThat(staticResourceJarUrls).isEmpty();
9292
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/Snake.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -141,7 +141,7 @@ public String getLocationsJson() {
141141
sb.append(',');
142142
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y)));
143143
}
144-
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb.toString());
144+
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb);
145145
}
146146
}
147147

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ public static void tick() throws Exception {
7777
sb.append(',');
7878
}
7979
}
80-
broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString()));
80+
broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb));
8181
}
8282

8383
public static void broadcast(String message) {

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeWebSocketHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio
7474
sb.append(',');
7575
}
7676
}
77-
SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb.toString()));
77+
SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb));
7878
}
7979

8080
@Override

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/Snake.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -141,7 +141,7 @@ public String getLocationsJson() {
141141
sb.append(',');
142142
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y)));
143143
}
144-
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb.toString());
144+
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb);
145145
}
146146
}
147147

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeTimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ public static void tick() throws Exception {
7777
sb.append(',');
7878
}
7979
}
80-
broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString()));
80+
broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb));
8181
}
8282

8383
public static void broadcast(String message) {

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/src/main/java/smoketest/websocket/tomcat/snake/SnakeWebSocketHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio
7474
sb.append(',');
7575
}
7676
}
77-
SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb.toString()));
77+
SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb));
7878
}
7979

8080
@Override

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Snake.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -141,7 +141,7 @@ public String getLocationsJson() {
141141
sb.append(',');
142142
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y)));
143143
}
144-
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb.toString());
144+
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb);
145145
}
146146
}
147147

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ public static void tick() throws Exception {
7777
sb.append(',');
7878
}
7979
}
80-
broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb.toString()));
80+
broadcast(String.format("{'type': 'update', 'data' : [%s]}", sb));
8181
}
8282

8383
public static void broadcast(String message) {

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio
7474
sb.append(',');
7575
}
7676
}
77-
SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb.toString()));
77+
SnakeTimer.broadcast(String.format("{'type': 'join','data':[%s]}", sb));
7878
}
7979

8080
@Override

0 commit comments

Comments
 (0)