Skip to content

Commit 2c1e81a

Browse files
committed
Polish
1 parent 1e38dd5 commit 2c1e81a

File tree

24 files changed

+65
-78
lines changed

24 files changed

+65
-78
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ protected ConditionOutcome getEndpointOutcome(ConditionContext context, String e
6969
}
7070

7171
protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) {
72-
boolean match = Boolean.valueOf(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true"));
72+
boolean match = Boolean
73+
.parseBoolean(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true"));
7374
return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType)
7475
.because(this.prefix + "defaults.enabled is considered " + match));
7576
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private ConfigurationPropertiesBeanDescriptor describeBean(ObjectMapper mapper,
186186
* @param prefix the prefix
187187
* @return the serialized instance
188188
*/
189-
@SuppressWarnings("unchecked")
189+
@SuppressWarnings({ "unchecked", "rawtypes" })
190190
private Map<String, Object> safeSerialize(ObjectMapper mapper, Object bean, String prefix) {
191191
try {
192192
return new HashMap<>(mapper.convertValue(bean, Map.class));

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ public PathMappedEndpoints(String basePath, Collection<EndpointsSupplier<?>> sup
6565

6666
private Map<EndpointId, PathMappedEndpoint> getEndpoints(Collection<EndpointsSupplier<?>> suppliers) {
6767
Map<EndpointId, PathMappedEndpoint> endpoints = new LinkedHashMap<>();
68-
suppliers.forEach((supplier) -> {
69-
supplier.getEndpoints().forEach((endpoint) -> {
70-
if (endpoint instanceof PathMappedEndpoint) {
71-
endpoints.put(endpoint.getEndpointId(), (PathMappedEndpoint) endpoint);
72-
}
73-
});
74-
});
68+
suppliers.forEach((supplier) -> supplier.getEndpoints().forEach((endpoint) -> {
69+
if (endpoint instanceof PathMappedEndpoint) {
70+
endpoints.put(endpoint.getEndpointId(), (PathMappedEndpoint) endpoint);
71+
}
72+
}));
7573
return Collections.unmodifiableMap(endpoints);
7674
}
7775

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public WebEndpointResponse<Health> map(Health health, SecurityContext securityCo
9999
}
100100

101101
private WebEndpointResponse<Health> createWebEndpointResponse(Health health) {
102-
Integer status = this.statusHttpMapper.mapStatus(health.getStatus());
102+
int status = this.statusHttpMapper.mapStatus(health.getStatus());
103103
return new WebEndpointResponse<>(health, status);
104104
}
105105

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ private void parseHostAndPort(String input, boolean sslEnabled) {
10591059
}
10601060
else {
10611061
this.host = input.substring(0, portIndex);
1062-
this.port = Integer.valueOf(input.substring(portIndex + 1));
1062+
this.port = Integer.parseInt(input.substring(portIndex + 1));
10631063
}
10641064
}
10651065

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisConnectionConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private List<RedisNode> createSentinels(RedisProperties.Sentinel sentinel) {
120120
try {
121121
String[] parts = StringUtils.split(node, ":");
122122
Assert.state(parts.length == 2, "Must be defined as 'host:port'");
123-
nodes.add(new RedisNode(parts[0], Integer.valueOf(parts[1])));
123+
nodes.add(new RedisNode(parts[0], Integer.parseInt(parts[1])));
124124
}
125125
catch (RuntimeException ex) {
126126
throw new IllegalStateException("Invalid redis sentinel property '" + node + "'", ex);

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConverters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
* needed, otherwise default converters will be used.
4545
* <p>
4646
* NOTE: The default converters used are the same as standard Spring MVC (see
47-
* {@link WebMvcConfigurationSupport#getMessageConverters} with some slight re-ordering to
48-
* put XML converters at the back of the list.
47+
* {@link WebMvcConfigurationSupport}) with some slight re-ordering to put XML converters
48+
* at the back of the list.
4949
*
5050
* @author Dave Syer
5151
* @author Phillip Webb

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ <T extends ActiveMQConnectionFactory> T createConnectionFactory(Class<T> factory
6868
}
6969

7070
private void startEmbeddedJms() {
71-
for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) {
72-
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
71+
for (String embeddedJmsClass : EMBEDDED_JMS_CLASSES) {
72+
if (ClassUtils.isPresent(embeddedJmsClass, null)) {
7373
try {
74-
this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASSES[i]));
74+
this.beanFactory.getBeansOfType(Class.forName(embeddedJmsClass));
7575
}
7676
catch (Exception ex) {
7777
// Ignore
@@ -103,8 +103,8 @@ private ArtemisMode deduceMode() {
103103
}
104104

105105
private boolean isEmbeddedJmsClassPresent() {
106-
for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) {
107-
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
106+
for (String embeddedJmsClass : EMBEDDED_JMS_CLASSES) {
107+
if (ClassUtils.isPresent(embeddedJmsClass, null)) {
108108
return true;
109109
}
110110
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private int determinePort(Environment environment) {
120120
Assert.notNull(environment, "Environment must not be null");
121121
String localPort = environment.getProperty("local.ldap.port");
122122
if (localPort != null) {
123-
return Integer.valueOf(localPort);
123+
return Integer.parseInt(localPort);
124124
}
125125
return DEFAULT_PORT;
126126
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,15 @@ private void customizeAccessLog(ConfigurableTomcatWebServerFactory factory) {
282282

283283
private void customizeStaticResources(ConfigurableTomcatWebServerFactory factory) {
284284
ServerProperties.Tomcat.Resource resource = this.serverProperties.getTomcat().getResource();
285-
factory.addContextCustomizers((context) -> {
286-
context.addLifecycleListener((event) -> {
287-
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
288-
context.getResources().setCachingAllowed(resource.isAllowCaching());
289-
if (resource.getCacheTtl() != null) {
290-
long ttl = resource.getCacheTtl().toMillis();
291-
context.getResources().setCacheTtl(ttl);
292-
}
285+
factory.addContextCustomizers((context) -> context.addLifecycleListener((event) -> {
286+
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
287+
context.getResources().setCachingAllowed(resource.isAllowCaching());
288+
if (resource.getCacheTtl() != null) {
289+
long ttl = resource.getCacheTtl().toMillis();
290+
context.getResources().setCacheTtl(ttl);
293291
}
294-
});
295-
});
292+
}
293+
}));
296294
}
297295

298296
private void customizeErrorReportValve(ErrorProperties error, ConfigurableTomcatWebServerFactory factory) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,13 @@ <T> Consumer<T> socket(Option<T> option) {
168168
return (value) -> this.factory.addBuilderCustomizers((builder) -> builder.setSocketOption(option, value));
169169
}
170170

171-
@SuppressWarnings("unchecked")
172171
<T> Consumer<Map<String, String>> forEach(Function<Option<T>, Consumer<T>> function) {
173-
return (map) -> {
174-
map.forEach((key, value) -> {
175-
Option<T> option = (Option<T>) NAME_LOOKUP.get(getCanonicalName(key));
176-
Assert.state(option != null, "Unable to find '" + key + "' in UndertowOptions");
177-
T parsed = option.parseValue(value, getClass().getClassLoader());
178-
function.apply(option).accept(parsed);
179-
});
180-
};
172+
return (map) -> map.forEach((key, value) -> {
173+
Option<T> option = (Option<T>) NAME_LOOKUP.get(getCanonicalName(key));
174+
Assert.state(option != null, "Unable to find '" + key + "' in UndertowOptions");
175+
T parsed = option.parseValue(value, getClass().getClassLoader());
176+
function.apply(option).accept(parsed);
177+
});
181178
}
182179

183180
private static String getCanonicalName(String name) {

spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.io.File;
2020
import java.io.FileInputStream;
21-
import java.io.FileNotFoundException;
2221
import java.io.IOException;
2322
import java.io.InputStream;
2423
import java.net.URI;
@@ -175,7 +174,7 @@ private List<MatchedResource> findMatchingClasspathEntries(List<URL> classpath,
175174
}
176175

177176
private void writeJar(File file, Class<?>[] compiledClasses, List<MatchedResource> classpathEntries,
178-
List<URL> dependencies) throws FileNotFoundException, IOException, URISyntaxException {
177+
List<URL> dependencies) throws IOException, URISyntaxException {
179178
final List<Library> libraries;
180179
try (JarWriter writer = new JarWriter(file)) {
181180
addManifest(writer, compiledClasses);

spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.cli.command.core;
1818

1919
import java.util.ArrayList;
20+
import java.util.Arrays;
2021
import java.util.Collections;
2122
import java.util.List;
2223

@@ -48,9 +49,7 @@ public ExitStatus run(String... args) throws Exception {
4849
try {
4950
int index = (args.length != 0) ? Integer.parseInt(args[0]) - 1 : 0;
5051
List<String> arguments = new ArrayList<>(args.length);
51-
for (int i = 2; i < args.length; i++) {
52-
arguments.add(args[i]);
53-
}
52+
arguments.addAll(Arrays.asList(args).subList(2, args.length));
5453
String starting = "";
5554
if (index < arguments.size()) {
5655
starting = arguments.remove(index);

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private void handle() throws Exception {
283283
}
284284
}
285285

286-
private void runConnection(Connection connection) throws IOException, Exception {
286+
private void runConnection(Connection connection) throws Exception {
287287
try {
288288
addConnection(connection);
289289
connection.run();

spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,14 @@ private Map<String, List<PropertyMigration>> getMatchingProperties(
9898
MultiValueMap<String, PropertyMigration> result = new LinkedMultiValueMap<>();
9999
List<ConfigurationMetadataProperty> candidates = this.allProperties.values().stream().filter(filter)
100100
.collect(Collectors.toList());
101-
getPropertySourcesAsMap().forEach((name, source) -> {
102-
candidates.forEach((metadata) -> {
103-
ConfigurationProperty configurationProperty = source
104-
.getConfigurationProperty(ConfigurationPropertyName.of(metadata.getId()));
105-
if (configurationProperty != null) {
106-
result.add(name, new PropertyMigration(configurationProperty, metadata,
107-
determineReplacementMetadata(metadata)));
108-
}
109-
});
110-
});
101+
getPropertySourcesAsMap().forEach((name, source) -> candidates.forEach((metadata) -> {
102+
ConfigurationProperty configurationProperty = source
103+
.getConfigurationProperty(ConfigurationPropertyName.of(metadata.getId()));
104+
if (configurationProperty != null) {
105+
result.add(name,
106+
new PropertyMigration(configurationProperty, metadata, determineReplacementMetadata(metadata)));
107+
}
108+
}));
111109
return result;
112110
}
113111

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,13 @@ protected abstract SELF newInstance(Supplier<C> contextFactory,
351351
* @param consumer the consumer of the created {@link ApplicationContext}
352352
* @return this instance
353353
*/
354-
@SuppressWarnings("unchecked")
355354
public SELF run(ContextConsumer<? super A> consumer) {
356-
withContextClassLoader(this.classLoader, () -> {
357-
this.systemProperties.applyToSystemProperties(() -> {
358-
try (A context = createAssertableContext()) {
359-
accept(consumer, context);
360-
}
361-
return null;
362-
});
363-
});
355+
withContextClassLoader(this.classLoader, () -> this.systemProperties.applyToSystemProperties(() -> {
356+
try (A context = createAssertableContext()) {
357+
accept(consumer, context);
358+
}
359+
return null;
360+
}));
364361
return (SELF) this;
365362
}
366363

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.lang.reflect.Field;
2121
import java.util.Arrays;
2222
import java.util.Collection;
23+
import java.util.Collections;
2324
import java.util.HashMap;
2425
import java.util.LinkedHashMap;
2526
import java.util.LinkedHashSet;
@@ -307,7 +308,7 @@ private String determinePrimaryCandidate(BeanDefinitionRegistry registry, Collec
307308
if (primaryBeanName != null) {
308309
throw new NoUniqueBeanDefinitionException(type.resolve(), candidateBeanNames.size(),
309310
"more than one 'primary' bean found among candidates: "
310-
+ Arrays.asList(candidateBeanNames));
311+
+ Collections.singletonList(candidateBeanNames));
311312
}
312313
primaryBeanName = candidateBeanName;
313314
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ private void processElement(Element element) {
181181
if (annotation != null) {
182182
String prefix = getPrefix(annotation);
183183
if (element instanceof TypeElement) {
184-
processAnnotatedTypeElement(prefix, (TypeElement) element, new Stack<TypeElement>());
184+
processAnnotatedTypeElement(prefix, (TypeElement) element, new Stack<>());
185185
}
186186
else if (element instanceof ExecutableElement) {
187-
processExecutableElement(prefix, (ExecutableElement) element, new Stack<TypeElement>());
187+
processExecutableElement(prefix, (ExecutableElement) element, new Stack<>());
188188
}
189189
}
190190
}

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected Iterator<Archive> getClassPathArchivesIterator() throws Exception {
7474
}
7575

7676
private Iterator<Archive> applyClassPathArchivePostProcessing(Iterator<Archive> archives) throws Exception {
77-
List<Archive> list = new ArrayList<Archive>();
77+
List<Archive> list = new ArrayList<>();
7878
while (archives.hasNext()) {
7979
list.add(archives.next());
8080
}

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected File getHomeDirectory() {
167167
}
168168
}
169169

170-
private void initializeProperties() throws Exception, IOException {
170+
private void initializeProperties() throws Exception {
171171
List<String> configs = new ArrayList<>();
172172
if (getProperty(CONFIG_LOCATION) != null) {
173173
configs.add(getProperty(CONFIG_LOCATION));
@@ -195,7 +195,7 @@ private void initializeProperties() throws Exception, IOException {
195195
}
196196
}
197197

198-
private void loadResource(InputStream resource) throws IOException, Exception {
198+
private void loadResource(InputStream resource) throws Exception {
199199
this.properties.load(resource);
200200
for (Object key : Collections.list(this.properties.propertyNames())) {
201201
String text = this.properties.getProperty((String) key);
@@ -591,7 +591,7 @@ private String cleanupPath(String path) {
591591
}
592592

593593
private List<Archive> asList(Iterator<Archive> iterator) {
594-
List<Archive> list = new ArrayList<Archive>();
594+
List<Archive> list = new ArrayList<>();
595595
while (iterator.hasNext()) {
596596
list.add(iterator.next());
597597
}

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ private static URL[] processUrls(URL[] urls, Class<?> testClass) {
172172
MergedAnnotations annotations = MergedAnnotations.from(testClass,
173173
MergedAnnotations.SearchStrategy.TYPE_HIERARCHY);
174174
ClassPathEntryFilter filter = new ClassPathEntryFilter(annotations.get(ClassPathExclusions.class));
175-
List<URL> processedUrls = new ArrayList<>();
176175
List<URL> additionalUrls = getAdditionalUrls(annotations.get(ClassPathOverrides.class));
177-
processedUrls.addAll(additionalUrls);
176+
List<URL> processedUrls = new ArrayList<>(additionalUrls);
178177
for (URL url : urls) {
179178
if (!filter.isExcluded(url)) {
180179
processedUrls.add(url);

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocatio
8181
}
8282

8383
private void runTestWithModifiedClassPath(ReflectiveInvocationContext<Method> invocationContext,
84-
ExtensionContext extensionContext) throws ClassNotFoundException, Throwable {
84+
ExtensionContext extensionContext) throws Throwable {
8585
Class<?> testClass = extensionContext.getRequiredTestClass();
8686
Method testMethod = invocationContext.getExecutable();
8787
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
@@ -95,8 +95,7 @@ private void runTestWithModifiedClassPath(ReflectiveInvocationContext<Method> in
9595
}
9696
}
9797

98-
private void runTest(ClassLoader classLoader, String testClassName, String testMethodName)
99-
throws ClassNotFoundException, Throwable {
98+
private void runTest(ClassLoader classLoader, String testClassName, String testMethodName) throws Throwable {
10099
Class<?> testClass = classLoader.loadClass(testClassName);
101100
Method testMethod = findMethod(testClass, testMethodName);
102101
LauncherDiscoveryRequest request = new LauncherDiscoveryRequestBuilder(classLoader)

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/compiler/TestCompiler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.util.Arrays;
2222
import java.util.Collection;
23+
import java.util.Collections;
2324

2425
import javax.annotation.processing.Processor;
2526
import javax.tools.JavaCompiler;
@@ -59,7 +60,7 @@ public TestCompiler(JavaCompiler compiler, File outputLocation) throws IOExcepti
5960
this.fileManager = compiler.getStandardFileManager(null, null, null);
6061
this.outputLocation = outputLocation;
6162
this.outputLocation.mkdirs();
62-
Iterable<? extends File> temp = Arrays.asList(this.outputLocation);
63+
Iterable<? extends File> temp = Collections.singletonList(this.outputLocation);
6364
this.fileManager.setLocation(StandardLocation.CLASS_OUTPUT, temp);
6465
this.fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, temp);
6566
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ private LoaderHidingResource(Resource delegate) {
521521
}
522522

523523
@Override
524-
public Resource addPath(String path) throws IOException, MalformedURLException {
524+
public Resource addPath(String path) throws IOException {
525525
if (path.startsWith("/org/springframework/boot")) {
526526
return null;
527527
}

0 commit comments

Comments
 (0)