Skip to content

Commit ae79a7c

Browse files
committed
Merge pull request #38739 from quaff
* pr/38739: Remove unnecessary `toString()` calls Remove unnecessary `extends Object` from generic Remove unnecessary `final` modifiers Remove unnecessary `static` modifiers Use `.isEmpty()` where feasible Closes gh-38739
2 parents d3af5cc + 8599e5a commit ae79a7c

File tree

45 files changed

+70
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+70
-72
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/autoconfigure/AutoConfigurationPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private Provider<AutoConfigurationImports> autoConfigurationImports(Project proj
154154
});
155155
}
156156

157-
private static record AutoConfigurationImports(Path importsFile, List<String> imports) {
157+
private record AutoConfigurationImports(Path importsFile, List<String> imports) {
158158

159159
}
160160

buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private void addClassifiedManagedDependencies(Node dependencyManagement) {
221221
.collect(Collectors.toSet());
222222
Node target = dependency;
223223
for (String classifier : classifiers) {
224-
if (classifier.length() > 0) {
224+
if (!classifier.isEmpty()) {
225225
if (target == null) {
226226
target = new Node(null, "dependency");
227227
target.appendNode("groupId", groupId);

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-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private Object getContributor(String[] path, int pathOffset) {
127127
private String getName(String[] path, int pathOffset) {
128128
StringBuilder name = new StringBuilder();
129129
while (pathOffset < path.length) {
130-
name.append((name.length() != 0) ? "/" : "");
130+
name.append((!name.isEmpty()) ? "/" : "");
131131
name.append(path[pathOffset]);
132132
pathOffset++;
133133
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ private String createOnBeanNoMatchReason(MatchResult matchResult) {
332332

333333
private void appendMessageForNoMatches(StringBuilder reason, Collection<String> unmatched, String description) {
334334
if (!unmatched.isEmpty()) {
335-
if (reason.length() > 0) {
335+
if (!reason.isEmpty()) {
336336
reason.append(" and ");
337337
}
338338
reason.append("did not find any beans ");
@@ -347,7 +347,7 @@ private String createOnMissingBeanNoMatchReason(MatchResult matchResult) {
347347
appendMessageForMatches(reason, matchResult.getMatchedAnnotations(), "annotated with");
348348
appendMessageForMatches(reason, matchResult.getMatchedTypes(), "of type");
349349
if (!matchResult.getMatchedNames().isEmpty()) {
350-
if (reason.length() > 0) {
350+
if (!reason.isEmpty()) {
351351
reason.append(" and ");
352352
}
353353
reason.append("found beans named ");
@@ -360,7 +360,7 @@ private void appendMessageForMatches(StringBuilder reason, Map<String, Collectio
360360
String description) {
361361
if (!matches.isEmpty()) {
362362
matches.forEach((key, value) -> {
363-
if (reason.length() > 0) {
363+
if (!reason.isEmpty()) {
364364
reason.append(" and ");
365365
}
366366
reason.append("found beans ");

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected File getHomeDirectory() {
144144
}
145145

146146
@SafeVarargs
147-
private final File getHomeDirectory(Supplier<String>... pathSuppliers) {
147+
private File getHomeDirectory(Supplier<String>... pathSuppliers) {
148148
for (Supplier<String> pathSupplier : pathSuppliers) {
149149
String path = pathSupplier.get();
150150
if (StringUtils.hasText(path)) {

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-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void parseMapShouldReturnContent() throws Exception {
169169
assertThat(tester.parse(MAP_JSON)).asMap().containsEntry("a", OBJECT);
170170
}
171171

172-
protected static final ExampleObject createExampleObject(String name, int age) {
172+
protected static ExampleObject createExampleObject(String name, int age) {
173173
ExampleObject exampleObject = new ExampleObject();
174174
exampleObject.setName(name);
175175
exampleObject.setAge(age);

spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ List<ContainerConnectionSource<?>> getSources() {
9191
* Relevant details from {@link ContainerConnectionSource} used as a
9292
* MergedContextConfiguration cache key.
9393
*/
94-
private static record CacheKey(String connectionName, Set<Class<?>> connectionDetailsTypes,
95-
Container<?> container) {
94+
private record CacheKey(String connectionName, Set<Class<?>> connectionDetailsTypes, Container<?> container) {
9695

9796
CacheKey(ContainerConnectionSource<?> source) {
9897
this(source.getConnectionName(), source.getConnectionDetailsTypes(), source.getContainerSupplier().get());

spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/ImportTestcontainersTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ interface ContainerDefinitions {
162162
}
163163

164164
@Retention(RetentionPolicy.RUNTIME)
165-
static @interface ContainerAnnotation {
165+
@interface ContainerAnnotation {
166166

167167
}
168168

spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ RedisContainer redisContainer(DynamicPropertyRegistry properties) {
6868
}
6969

7070
@ConfigurationProperties("container")
71-
static record ContainerProperties(int port) {
71+
record ContainerProperties(int port) {
7272
}
7373

7474
static class TestBean {

spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ private String toCommaDelimitedString(List<Object> list) {
345345
}
346346
StringBuilder result = new StringBuilder();
347347
for (Object item : list) {
348-
result.append((result.length() != 0) ? "," : "");
348+
result.append((!result.isEmpty()) ? "," : "");
349349
result.append(item);
350350
}
351351
return result.toString();

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public JSONStringer endObject() throws JSONException {
173173
* @throws JSONException if processing of json failed
174174
*/
175175
JSONStringer open(Scope empty, String openBracket) throws JSONException {
176-
if (this.stack.isEmpty() && this.out.length() > 0) {
176+
if (this.stack.isEmpty() && !this.out.isEmpty()) {
177177
throw new JSONException("Nesting problem: multiple top-level roots");
178178
}
179179
beforeValue();
@@ -423,7 +423,7 @@ else if (context != Scope.NULL) {
423423
*/
424424
@Override
425425
public String toString() {
426-
return this.out.length() == 0 ? null : this.out.toString();
426+
return this.out.isEmpty() ? null : this.out.toString();
427427
}
428428

429429
}

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.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.
@@ -65,7 +65,7 @@ private String buildName(String prefix, String name) {
6565
fullName.append(prefix);
6666
}
6767
if (name != null) {
68-
if (fullName.length() > 0) {
68+
if (!fullName.isEmpty()) {
6969
fullName.append('.');
7070
}
7171
fullName.append(ConfigurationMetadata.toDashedCase(name));

spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/TestPrintStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838
class TestPrintStream extends PrintStream implements AssertProvider<PrintStreamAssert> {
3939

40-
private final Class<? extends Object> testClass;
40+
private final Class<?> testClass;
4141

4242
TestPrintStream(Object testInstance) {
4343
super(new ByteArrayOutputStream());

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
227227
}
228228

229229
boolean hasReportedErrors() {
230-
return this.message.length() > 0;
230+
return !this.message.isEmpty();
231231
}
232232

233233
@Override

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ private void addClasspath(List<String> args) throws MojoExecutionException {
329329
try {
330330
StringBuilder classpath = new StringBuilder();
331331
for (URL ele : getClassPathUrls()) {
332-
if (classpath.length() > 0) {
332+
if (!classpath.isEmpty()) {
333333
classpath.append(File.pathSeparator);
334334
}
335335
classpath.append(new File(ele.toURI()));

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CommandLineBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static class ClasspathBuilder {
9898
static String build(List<URL> classpathElements) {
9999
StringBuilder classpath = new StringBuilder();
100100
for (URL element : classpathElements) {
101-
if (classpath.length() > 0) {
101+
if (!classpath.isEmpty()) {
102102
classpath.append(File.pathSeparator);
103103
}
104104
classpath.append(toFile(element));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java

Lines changed: 3 additions & 3 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.
@@ -121,7 +121,7 @@ private void appendContext(StringBuilder message) {
121121
}
122122
append(context, "started by ", () -> System.getProperty("user.name"));
123123
append(context, "in ", () -> System.getProperty("user.dir"));
124-
if (context.length() > 0) {
124+
if (!context.isEmpty()) {
125125
message.append(" (");
126126
message.append(context);
127127
message.append(")");
@@ -143,7 +143,7 @@ private void append(StringBuilder message, String prefix, Callable<Object> call,
143143
value = defaultValue;
144144
}
145145
if (StringUtils.hasLength(value)) {
146-
message.append((message.length() > 0) ? " " : "");
146+
message.append((!message.isEmpty()) ? " " : "");
147147
message.append(prefix);
148148
message.append(value);
149149
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DataObjectPropertyName.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.
@@ -52,7 +52,7 @@ public static String toDashedForm(String name) {
5252
}
5353
else {
5454
ch = (ch != '_') ? ch : '-';
55-
if (Character.isUpperCase(ch) && result.length() > 0 && result.charAt(result.length() - 1) != '-') {
55+
if (Character.isUpperCase(ch) && !result.isEmpty() && result.charAt(result.length() - 1) != '-') {
5656
result.append('-');
5757
}
5858
result.append(Character.toLowerCase(ch));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private boolean isScalarValue(ConfigurationPropertySource source, ConfigurationP
211211
private String getKeyName(ConfigurationPropertyName name) {
212212
StringBuilder result = new StringBuilder();
213213
for (int i = this.root.getNumberOfElements(); i < name.getNumberOfElements(); i++) {
214-
if (result.length() != 0) {
214+
if (!result.isEmpty()) {
215215
result.append('.');
216216
}
217217
result.append(name.getElement(i, Form.ORIGINAL));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ private String buildToString() {
543543
StringBuilder result = new StringBuilder(elements * 8);
544544
for (int i = 0; i < elements; i++) {
545545
boolean indexed = isIndexed(i);
546-
if (result.length() > 0 && !indexed) {
546+
if (!result.isEmpty() && !indexed) {
547547
result.append('.');
548548
}
549549
if (indexed) {
@@ -615,7 +615,7 @@ private static Elements elementsOf(CharSequence name, boolean returnNullIfInvali
615615
Assert.isTrue(returnNullIfInvalid, "Name must not be null");
616616
return null;
617617
}
618-
if (name.length() == 0) {
618+
if (name.isEmpty()) {
619619
return Elements.EMPTY;
620620
}
621621
if (name.charAt(0) == '.' || name.charAt(name.length() - 1) == '.') {
@@ -674,7 +674,7 @@ public static ConfigurationPropertyName adapt(CharSequence name, char separator)
674674
static ConfigurationPropertyName adapt(CharSequence name, char separator,
675675
Function<CharSequence, CharSequence> elementValueProcessor) {
676676
Assert.notNull(name, "Name must not be null");
677-
if (name.length() == 0) {
677+
if (name.isEmpty()) {
678678
return EMPTY;
679679
}
680680
Elements elements = new ElementsParser(name, separator).parse(elementValueProcessor);

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java

Lines changed: 3 additions & 3 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.
@@ -57,7 +57,7 @@ private String convertName(ConfigurationPropertyName name) {
5757
private String convertName(ConfigurationPropertyName name, int numberOfElements) {
5858
StringBuilder result = new StringBuilder();
5959
for (int i = 0; i < numberOfElements; i++) {
60-
if (result.length() > 0) {
60+
if (!result.isEmpty()) {
6161
result.append('_');
6262
}
6363
result.append(name.getElement(i, Form.UNIFORM).toUpperCase(Locale.ENGLISH));
@@ -68,7 +68,7 @@ private String convertName(ConfigurationPropertyName name, int numberOfElements)
6868
private String convertLegacyName(ConfigurationPropertyName name) {
6969
StringBuilder result = new StringBuilder();
7070
for (int i = 0; i < name.getNumberOfElements(); i++) {
71-
if (result.length() > 0) {
71+
if (!result.isEmpty()) {
7272
result.append('_');
7373
}
7474
result.append(convertLegacyNameElement(name.getElement(i, Form.ORIGINAL)));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.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.
@@ -158,7 +158,7 @@ else if (current == '\\') {
158158
}
159159
index++;
160160
}
161-
if (build.length() > 0) {
161+
if (!build.isEmpty()) {
162162
list.add(build.toString().trim());
163163
}
164164
return list;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void format(LogEvent event, StringBuilder toAppendTo) {
130130
for (PatternFormatter formatter : this.formatters) {
131131
formatter.format(event, buf);
132132
}
133-
if (buf.length() > 0) {
133+
if (!buf.isEmpty()) {
134134
AnsiElement element = this.styling;
135135
if (element == null) {
136136
// Assume highlighting

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) {
258258
List<Throwable> suppressedExceptions = new ArrayList<>();
259259
for (Status status : loggerContext.getStatusManager().getCopyOfStatusList()) {
260260
if (status.getLevel() == Status.ERROR) {
261-
errors.append((errors.length() > 0) ? String.format("%n") : "");
262-
errors.append(status.toString());
261+
errors.append((!errors.isEmpty()) ? String.format("%n") : "");
262+
errors.append(status);
263263
if (status.getThrowable() != null) {
264264
suppressedExceptions.add(status.getThrowable());
265265
}
266266
}
267267
}
268-
if (errors.length() == 0) {
268+
if (errors.isEmpty()) {
269269
if (!StatusUtil.contextHasStatusListener(loggerContext)) {
270270
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
271271
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ ConnectionFactory buildAndWrap(ConnectionFactoryOptions options) {
212212

213213
private ConnectionFactoryOptions delegateFactoryOptions(ConnectionFactoryOptions options) {
214214
String protocol = toString(options.getRequiredValue(ConnectionFactoryOptions.PROTOCOL));
215-
if (protocol.trim().length() == 0) {
215+
if (protocol.trim().isEmpty()) {
216216
throw new IllegalArgumentException(String.format("Protocol %s is not valid.", protocol));
217217
}
218218
String[] protocols = protocol.split(COLON, 2);

0 commit comments

Comments
 (0)