Skip to content

Commit 7bc535e

Browse files
committed
Polish
1 parent 67998e9 commit 7bc535e

File tree

13 files changed

+110
-128
lines changed

13 files changed

+110
-128
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ private RequestMappingInfo withEndpointMappedPatterns(
9595
ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) {
9696
Set<PathPattern> patterns = mapping.getPatternsCondition().getPatterns();
9797
if (patterns.isEmpty()) {
98-
patterns = new HashSet<>(
99-
Arrays.asList(getPathPatternParser().parse("")));
98+
patterns = new HashSet<>(Arrays.asList(getPathPatternParser().parse("")));
10099
}
101100
PathPattern[] endpointMappedPatterns = patterns.stream()
102101
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern))

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ static class Hikari {
6464
public void validateMBeans() {
6565
HikariDataSource hikariDataSource = unwrapHikariDataSource();
6666
if (hikariDataSource != null && hikariDataSource.isRegisterMbeans()) {
67-
this.mBeanExporter.ifUnique((exporter) ->
68-
exporter.addExcludedBean("dataSource"));
67+
this.mBeanExporter
68+
.ifUnique((exporter) -> exporter.addExcludedBean("dataSource"));
6969
}
7070
}
7171

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,10 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
218218
AnnotatedTypeMetadata metadata) {
219219
Builder message = ConditionMessage.forCondition("Embedded LDAP");
220220
Environment environment = context.getEnvironment();
221-
if (environment != null
222-
&& !Binder.get(environment)
223-
.bind("spring.ldap.embedded.base-dn", STRING_LIST)
224-
.orElseGet(Collections::emptyList).isEmpty()) {
225-
return ConditionOutcome
226-
.match(message.because("Found base-dn property"));
221+
if (environment != null && !Binder.get(environment)
222+
.bind("spring.ldap.embedded.base-dn", STRING_LIST)
223+
.orElseGet(Collections::emptyList).isEmpty()) {
224+
return ConditionOutcome.match(message.because("Found base-dn property"));
227225
}
228226
return ConditionOutcome.noMatch(message.because("No base-dn property found"));
229227
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ protected void onApplicationEvent(ApplicationEvent event) {
7575
}
7676
}
7777
else if (event instanceof ApplicationFailedEvent
78-
&& ((ApplicationFailedEvent) event)
79-
.getApplicationContext() == initializerApplicationContext) {
78+
&& ((ApplicationFailedEvent) event)
79+
.getApplicationContext() == initializerApplicationContext) {
8080
logAutoConfigurationReport(true);
8181
}
8282
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfigurationTests.java

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,26 @@
4949
public class DataSourceJmxConfigurationTests {
5050

5151
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
52-
.withPropertyValues("spring.datasource.url="
53-
+ "jdbc:hsqldb:mem:test-" + UUID.randomUUID())
52+
.withPropertyValues("spring.datasource.url=" + "jdbc:hsqldb:mem:test-"
53+
+ UUID.randomUUID())
5454
.withConfiguration(AutoConfigurations.of(JmxAutoConfiguration.class,
5555
DataSourceAutoConfiguration.class));
5656

5757
@Test
5858
public void hikariAutoConfiguredCanUseRegisterMBeans() {
5959
String poolName = UUID.randomUUID().toString();
60-
this.contextRunner.withPropertyValues(
61-
"spring.datasource.type=" + HikariDataSource.class.getName(),
62-
"spring.datasource.name=" + poolName,
63-
"spring.datasource.hikari.register-mbeans=true").run((context) -> {
64-
assertThat(context).hasSingleBean(HikariDataSource.class);
65-
assertThat(context.getBean(HikariDataSource.class).isRegisterMbeans())
66-
.isTrue();
67-
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
68-
validateHikariMBeansRegistration(mBeanServer, poolName, true);
69-
});
60+
this.contextRunner
61+
.withPropertyValues(
62+
"spring.datasource.type=" + HikariDataSource.class.getName(),
63+
"spring.datasource.name=" + poolName,
64+
"spring.datasource.hikari.register-mbeans=true")
65+
.run((context) -> {
66+
assertThat(context).hasSingleBean(HikariDataSource.class);
67+
assertThat(context.getBean(HikariDataSource.class).isRegisterMbeans())
68+
.isTrue();
69+
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
70+
validateHikariMBeansRegistration(mBeanServer, poolName, true);
71+
});
7072
}
7173

7274
@Test
@@ -75,34 +77,39 @@ public void hikariAutoConfiguredWithoutDataSourceName()
7577
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
7678
Set<ObjectInstance> existingInstances = mBeanServer
7779
.queryMBeans(new ObjectName("com.zaxxer.hikari:type=*"), null);
78-
this.contextRunner.withPropertyValues(
79-
"spring.datasource.type=" + HikariDataSource.class.getName(),
80-
"spring.datasource.hikari.register-mbeans=true").run((context) -> {
81-
assertThat(context).hasSingleBean(HikariDataSource.class);
82-
assertThat(context.getBean(HikariDataSource.class).isRegisterMbeans())
83-
.isTrue();
84-
// We can't rely on the number of MBeans so we're checking that the pool and pool
85-
// config MBeans were registered
86-
assertThat(mBeanServer
87-
.queryMBeans(new ObjectName("com.zaxxer.hikari:type=*"), null).size())
88-
.isEqualTo(existingInstances.size() + 2);
89-
});
80+
this.contextRunner
81+
.withPropertyValues(
82+
"spring.datasource.type=" + HikariDataSource.class.getName(),
83+
"spring.datasource.hikari.register-mbeans=true")
84+
.run((context) -> {
85+
assertThat(context).hasSingleBean(HikariDataSource.class);
86+
assertThat(context.getBean(HikariDataSource.class).isRegisterMbeans())
87+
.isTrue();
88+
// We can't rely on the number of MBeans so we're checking that the
89+
// pool and pool
90+
// config MBeans were registered
91+
assertThat(mBeanServer
92+
.queryMBeans(new ObjectName("com.zaxxer.hikari:type=*"), null)
93+
.size()).isEqualTo(existingInstances.size() + 2);
94+
});
9095
}
9196

9297
@Test
9398
public void hikariAutoConfiguredUsesJmsFlag() {
9499
String poolName = UUID.randomUUID().toString();
95-
this.contextRunner.withPropertyValues(
96-
"spring.datasource.type=" + HikariDataSource.class.getName(),
97-
"spring.jmx.enabled=false", "spring.datasource.name=" + poolName,
98-
"spring.datasource.hikari.register-mbeans=true").run((context) -> {
99-
assertThat(context).hasSingleBean(HikariDataSource.class);
100-
assertThat(context.getBean(HikariDataSource.class).isRegisterMbeans())
101-
.isTrue();
102-
// Hikari can still register mBeans
103-
validateHikariMBeansRegistration(ManagementFactory.getPlatformMBeanServer(),
104-
poolName, true);
105-
});
100+
this.contextRunner
101+
.withPropertyValues(
102+
"spring.datasource.type=" + HikariDataSource.class.getName(),
103+
"spring.jmx.enabled=false", "spring.datasource.name=" + poolName,
104+
"spring.datasource.hikari.register-mbeans=true")
105+
.run((context) -> {
106+
assertThat(context).hasSingleBean(HikariDataSource.class);
107+
assertThat(context.getBean(HikariDataSource.class).isRegisterMbeans())
108+
.isTrue();
109+
// Hikari can still register mBeans
110+
validateHikariMBeansRegistration(
111+
ManagementFactory.getPlatformMBeanServer(), poolName, true);
112+
});
106113
}
107114

108115
@Test
@@ -115,8 +122,9 @@ public void hikariProxiedCanUseRegisterMBeans() {
115122
"spring.datasource.hikari.register-mbeans=true")
116123
.run((context) -> {
117124
assertThat(context).hasSingleBean(javax.sql.DataSource.class);
118-
HikariDataSource hikariDataSource = context.getBean(
119-
javax.sql.DataSource.class).unwrap(HikariDataSource.class);
125+
HikariDataSource hikariDataSource = context
126+
.getBean(javax.sql.DataSource.class)
127+
.unwrap(HikariDataSource.class);
120128
assertThat(hikariDataSource.isRegisterMbeans()).isTrue();
121129
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
122130
validateHikariMBeansRegistration(mBeanServer, poolName, true);
@@ -127,29 +135,31 @@ private void validateHikariMBeansRegistration(MBeanServer mBeanServer,
127135
String poolName, boolean expected) throws MalformedObjectNameException {
128136
assertThat(mBeanServer.isRegistered(
129137
new ObjectName("com.zaxxer.hikari:type=Pool (" + poolName + ")")))
130-
.isEqualTo(expected);
138+
.isEqualTo(expected);
131139
assertThat(mBeanServer.isRegistered(
132140
new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + poolName + ")")))
133-
.isEqualTo(expected);
141+
.isEqualTo(expected);
134142
}
135143

136144
@Test
137145
public void tomcatDoesNotExposeMBeanPoolByDefault() {
138146
this.contextRunner
139-
.withPropertyValues("spring.datasource.type=" + DataSource.class.getName())
140-
.run((context) ->
141-
assertThat(context).doesNotHaveBean(ConnectionPool.class));
147+
.withPropertyValues(
148+
"spring.datasource.type=" + DataSource.class.getName())
149+
.run((context) -> assertThat(context)
150+
.doesNotHaveBean(ConnectionPool.class));
142151
}
143152

144153
@Test
145154
public void tomcatAutoConfiguredCanExposeMBeanPool() {
146155
this.contextRunner.withPropertyValues(
147156
"spring.datasource.type=" + DataSource.class.getName(),
148157
"spring.datasource.jmx-enabled=true").run((context) -> {
149-
assertThat(context).hasSingleBean(ConnectionPool.class);
150-
assertThat(context.getBean(DataSourceProxy.class).createPool().getJmxPool())
151-
.isSameAs(context.getBean(ConnectionPool.class));
152-
});
158+
assertThat(context).hasSingleBean(ConnectionPool.class);
159+
assertThat(context.getBean(DataSourceProxy.class).createPool()
160+
.getJmxPool())
161+
.isSameAs(context.getBean(ConnectionPool.class));
162+
});
153163
}
154164

155165
@Configuration
@@ -162,7 +172,6 @@ public static DataSourceBeanPostProcessor dataSourceBeanPostProcessor() {
162172

163173
}
164174

165-
166175
private static class DataSourceBeanPostProcessor implements BeanPostProcessor {
167176

168177
@Override

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java

Lines changed: 1 addition & 1 deletion
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.

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java

Lines changed: 1 addition & 1 deletion
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.

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/PomCondition.java

Lines changed: 1 addition & 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.
@@ -22,8 +22,6 @@
2222
import java.util.HashSet;
2323
import java.util.Set;
2424

25-
import org.assertj.core.api.Condition;
26-
import org.assertj.core.description.Description;
2725
import org.assertj.core.description.TextDescription;
2826

2927
import org.springframework.util.FileCopyUtils;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ static JarURLConnection get(URL url, JarFile jarFile) throws IOException {
266266
index = separator + SEPARATOR.length();
267267
}
268268
JarEntryName jarEntryName = JarEntryName.get(spec, index);
269-
if (Boolean.TRUE.equals(useFastExceptions.get())
270-
&& !jarEntryName.isEmpty()
269+
if (Boolean.TRUE.equals(useFastExceptions.get()) && !jarEntryName.isEmpty()
271270
&& !jarFile.containsEntry(jarEntryName.toString())) {
272271
return NOT_FOUND_CONNECTION;
273272
}

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

Lines changed: 1 addition & 1 deletion
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.

0 commit comments

Comments
 (0)