Skip to content

Commit 8e783cd

Browse files
committed
Polish
1 parent 71ab5dd commit 8e783cd

File tree

8 files changed

+46
-44
lines changed

8 files changed

+46
-44
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.autoconfigure.web;
1818

19+
import reactor.core.support.Assert;
20+
1921
import org.springframework.beans.BeansException;
2022
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2123
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -80,14 +82,11 @@ public void customize(ConfigurableEmbeddedServletContainer container) {
8082
// a single bean
8183
String[] serverPropertiesBeans = this.applicationContext
8284
.getBeanNamesForType(ServerProperties.class);
83-
if (serverPropertiesBeans.length == 0) {
84-
throw new IllegalStateException("No ServerProperties bean registered");
85-
}
86-
if (serverPropertiesBeans.length > 1) {
87-
throw new IllegalStateException(
88-
"Multiple ServerProperties beans registered " + StringUtils
89-
.arrayToCommaDelimitedString(serverPropertiesBeans));
90-
}
85+
Assert.state(serverPropertiesBeans.length != 0,
86+
"No ServerProperties registered");
87+
Assert.state(serverPropertiesBeans.length == 1,
88+
"Multiple ServerProperties registered " + StringUtils
89+
.arrayToCommaDelimitedString(serverPropertiesBeans));
9190
}
9291

9392
}

spring-boot-integration-tests/spring-boot-configuration-processor-tests/pom.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
54
<modelVersion>4.0.0</modelVersion>
65
<parent>
76
<groupId>org.springframework.boot</groupId>
@@ -34,7 +33,6 @@
3433
<!-- this override is required to reproduce an issue -->
3534
<version>2.0.1.Final</version>
3635
</dependency>
37-
3836
<dependency>
3937
<groupId>org.springframework.boot</groupId>
4038
<artifactId>spring-boot-configuration-processor</artifactId>

spring-boot-integration-tests/spring-boot-configuration-processor-tests/src/test/java/org/springframework/boot/configurationprocessor/tests/ConfigurationProcessorIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ public static void readMetadata() throws IOException {
4444
"META-INF/spring-configuration-metadata.json");
4545
assertThat(resource.exists()).isTrue();
4646
// Make sure the right file is detected
47-
assertThat(resource.getURL().toString()).contains(
48-
"spring-boot-configuration-processor-tests");
47+
assertThat(resource.getURL().toString())
48+
.contains("spring-boot-configuration-processor-tests");
4949
repository = ConfigurationMetadataRepositoryJsonBuilder
5050
.create(resource.getInputStream()).build();
5151

5252
}
5353

5454
@Test
5555
public void extractTypeFromAnnotatedGetter() {
56-
ConfigurationMetadataProperty property = repository.getAllProperties().get(
57-
"annotated.name");
56+
ConfigurationMetadataProperty property = repository.getAllProperties()
57+
.get("annotated.name");
5858
assertThat(property).isNotNull();
5959
assertThat(property.getType()).isEqualTo("java.lang.String");
6060
}

spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 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.
@@ -75,8 +75,9 @@ private List<URL> findJsonObjects() {
7575
}
7676

7777
private void logDuplicateJsonObjectsWarning(List<URL> jsonObjects) {
78-
StringBuilder message = new StringBuilder(String.format("%n%nFound multiple occurrences of"
79-
+ " org.json.JSONObject on the class path:%n%n"));
78+
StringBuilder message = new StringBuilder(
79+
String.format("%n%nFound multiple occurrences of"
80+
+ " org.json.JSONObject on the class path:%n%n"));
8081
for (URL jsonObject : jsonObjects) {
8182
message.append(String.format("\t%s%n", jsonObject));
8283
}

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ private TypeKind getPrimitiveFor(TypeMirror type) {
168168
return WRAPPER_TO_PRIMITIVE.get(type.toString());
169169
}
170170

171-
172171
/**
173172
* A visitor that extracts the full qualified name of a type, including generic
174173
* information.
@@ -188,21 +187,24 @@ public String visitDeclared(DeclaredType type, Void none) {
188187
return getQualifiedName(enclosingElement) + "$"
189188
+ type.asElement().getSimpleName().toString();
190189
}
191-
StringBuilder sb = new StringBuilder();
192-
sb.append(getQualifiedName(type.asElement()));
190+
StringBuilder name = new StringBuilder();
191+
name.append(getQualifiedName(type.asElement()));
193192
if (!type.getTypeArguments().isEmpty()) {
194-
sb.append("<");
195-
Iterator<?> it = type.getTypeArguments().iterator();
196-
while (it.hasNext()) {
197-
sb.append(it.next());
198-
if (it.hasNext()) {
199-
sb.append(",");
200-
}
201-
}
202-
sb.append(">");
193+
appendTypeArguments(type, name);
194+
}
195+
return name.toString();
196+
}
203197

198+
private void appendTypeArguments(DeclaredType type, StringBuilder name) {
199+
name.append("<");
200+
Iterator<?> iterator = type.getTypeArguments().iterator();
201+
while (iterator.hasNext()) {
202+
name.append(iterator.next());
203+
if (iterator.hasNext()) {
204+
name.append(",");
205+
}
204206
}
205-
return sb.toString();
207+
name.append(">");
206208
}
207209

208210
@Override
@@ -223,7 +225,7 @@ public String getQualifiedName(Element element) {
223225
if (enclosingElement != null) {
224226
return getQualifiedName(enclosingElement) + "$"
225227
+ ((DeclaredType) element.asType()).asElement().getSimpleName()
226-
.toString();
228+
.toString();
227229
}
228230
if (element instanceof TypeElement) {
229231
return ((TypeElement) element).getQualifiedName().toString();

spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ public void parseCollectionConfig() throws Exception {
261261
@Test
262262
public void parseArrayConfig() throws Exception {
263263
ConfigurationMetadata metadata = compile(SimpleArrayProperties.class);
264-
assertThat(metadata).has(Metadata.withGroup("array")
265-
.ofType(SimpleArrayProperties.class));
266-
assertThat(metadata).has(Metadata.withProperty("array.primitive",
267-
"java.lang.Integer[]"));
268-
assertThat(metadata).has(Metadata.withProperty("array.simple",
269-
"java.lang.String[]"));
264+
assertThat(metadata)
265+
.has(Metadata.withGroup("array").ofType(SimpleArrayProperties.class));
266+
assertThat(metadata)
267+
.has(Metadata.withProperty("array.primitive", "java.lang.Integer[]"));
268+
assertThat(metadata)
269+
.has(Metadata.withProperty("array.simple", "java.lang.String[]"));
270270
assertThat(metadata).has(Metadata.withProperty("array.inner",
271271
"org.springframework.boot.configurationsample.simple.SimpleArrayProperties$Holder[]"));
272272
assertThat(metadata).has(Metadata.withProperty("array.name-to-integer",
@@ -464,8 +464,8 @@ public void genericTypes() throws IOException {
464464
@Test
465465
public void wildcardTypes() throws IOException {
466466
ConfigurationMetadata metadata = compile(WildcardConfig.class);
467-
assertThat(metadata).has(Metadata.withGroup("wildcard")
468-
.ofType(WildcardConfig.class));
467+
assertThat(metadata)
468+
.has(Metadata.withGroup("wildcard").ofType(WildcardConfig.class));
469469
assertThat(metadata).has(Metadata.withProperty("wildcard.string-to-number")
470470
.ofType("java.util.Map<java.lang.String,? extends java.lang.Number>")
471471
.fromSource(WildcardConfig.class));

spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/SimpleCollectionProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public Map<String, Holder<String>> getNamesToHolders() {
8989

9090
public static class Holder<T> {
9191

92+
@SuppressWarnings("unused")
9293
private T target;
9394

9495
public void setTarget(T target) {

spring-boot/src/test/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListenerTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public void replaceServiceLocatorBacksOffIfNotPresent()
6868
SpringApplication application = new SpringApplication(Conf.class);
6969
application.setWebEnvironment(false);
7070
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
71-
resourceLoader.setClassLoader(new ClassHidingClassLoader(
72-
CustomResolverServiceLocator.class));
71+
resourceLoader.setClassLoader(
72+
new ClassHidingClassLoader(CustomResolverServiceLocator.class));
7373
application.setResourceLoader(resourceLoader);
7474
this.context = application.run();
7575
Object resolver = getServiceLocator();
@@ -93,7 +93,8 @@ private final class ClassHidingClassLoader extends URLClassLoader {
9393
private final List<Class<?>> hiddenClasses;
9494

9595
private ClassHidingClassLoader(Class<?>... hiddenClasses) {
96-
super(new URL[0], LiquibaseServiceLocatorApplicationListenerTests.class.getClassLoader());
96+
super(new URL[0], LiquibaseServiceLocatorApplicationListenerTests.class
97+
.getClassLoader());
9798
this.hiddenClasses = Arrays.asList(hiddenClasses);
9899
}
99100

0 commit comments

Comments
 (0)