Skip to content

Commit cf93f84

Browse files
committed
Polish
1 parent acfae2e commit cf93f84

File tree

12 files changed

+56
-44
lines changed

12 files changed

+56
-44
lines changed

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ public void testDetailsAreIncludedInAuditEvent() throws Exception {
100100
assertThat(auditApplicationEvent.getValue().getAuditEvent().getData(),
101101
hasEntry("details", details));
102102
}
103+
103104
}

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,27 @@ public FlywayJpaDependencyConfiguration() {
183183
private static class StringOrNumberToMigrationVersionConverter
184184
implements GenericConverter {
185185

186-
private static final Set<ConvertiblePair> CONVERTIBLE_PAIRS = createConvertiblePairs();
186+
private static final Set<ConvertiblePair> CONVERTIBLE_TYPES;
187+
188+
static {
189+
Set<ConvertiblePair> types = new HashSet<ConvertiblePair>(2);
190+
types.add(new ConvertiblePair(String.class, MigrationVersion.class));
191+
types.add(new ConvertiblePair(Number.class, MigrationVersion.class));
192+
CONVERTIBLE_TYPES = Collections.unmodifiableSet(types);
193+
}
187194

188195
@Override
189196
public Set<ConvertiblePair> getConvertibleTypes() {
190-
return CONVERTIBLE_PAIRS;
197+
return CONVERTIBLE_TYPES;
191198
}
192199

193200
@Override
194-
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
201+
public Object convert(Object source, TypeDescriptor sourceType,
202+
TypeDescriptor targetType) {
195203
String value = ObjectUtils.nullSafeToString(source);
196204
return MigrationVersion.fromVersion(value);
197205
}
198206

199-
private static Set<ConvertiblePair> createConvertiblePairs() {
200-
Set<ConvertiblePair> convertiblePairs = new HashSet<ConvertiblePair>(2);
201-
convertiblePairs.add(new ConvertiblePair(String.class, MigrationVersion.class));
202-
convertiblePairs.add(new ConvertiblePair(Number.class, MigrationVersion.class));
203-
return Collections.unmodifiableSet(convertiblePairs);
204-
}
205-
206207
}
207208

208209
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
/**
2828
* {@link Conditional} that checks whether or not the Spring resource handling chain is
29-
* enabled. Matches if {@link ResourceProperties.Chain#getEnabled()} is {@code true} or
30-
* if {@code webjars-locator} is on the classpath.
29+
* enabled. Matches if {@link ResourceProperties.Chain#getEnabled()} is {@code true} or if
30+
* {@code webjars-locator} is on the classpath.
3131
*
3232
* @author Stephane Nicoll
3333
* @since 1.3.0

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
class OnEnabledResourceChainCondition extends SpringBootCondition {
3636

37-
public static final String WEBJAR_ASSERT_LOCATOR = "org.webjars.WebJarAssetLocator";
37+
private static final String WEBJAR_ASSERT_LOCATOR = "org.webjars.WebJarAssetLocator";
3838

3939
@Override
4040
public ConditionOutcome getMatchOutcome(ConditionContext context,
@@ -46,8 +46,8 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
4646
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
4747
Boolean match = properties.getChain().getEnabled();
4848
if (match == null) {
49-
boolean webJarsLocatorPresent = ClassUtils.isPresent(
50-
WEBJAR_ASSERT_LOCATOR, getClass().getClassLoader());
49+
boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
50+
getClass().getClassLoader());
5151
return new ConditionOutcome(webJarsLocatorPresent,
5252
"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
5353
+ (webJarsLocatorPresent ? "present" : "absent"));

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -175,11 +175,10 @@ public static class Chain {
175175
/**
176176
* Return whether the resource chain is enabled. Return {@code null} if no
177177
* specific settings are present.
178-
* @return whether the resource chain is enabled or {@code null} if no
179-
* specified settings are present.
178+
* @return whether the resource chain is enabled or {@code null} if no specified
179+
* settings are present.
180180
*/
181181
public Boolean getEnabled() {
182-
// Check if at least one of the available strategy has been enabled
183182
Boolean strategyEnabled = getStrategy().getFixed().isEnabled()
184183
|| getStrategy().getContent().isEnabled();
185184
return (strategyEnabled ? Boolean.TRUE : this.enabled);

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,24 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
258258
}
259259
Integer cachePeriod = this.resourceProperties.getCachePeriod();
260260
if (!registry.hasMappingForPattern("/webjars/**")) {
261-
customizeResourceHandlerRegistration(registry.addResourceHandler("/webjars/**")
262-
.addResourceLocations("classpath:/META-INF/resources/webjars/")
261+
customizeResourceHandlerRegistration(
262+
registry.addResourceHandler("/webjars/**")
263+
.addResourceLocations(
264+
"classpath:/META-INF/resources/webjars/")
263265
.setCachePeriod(cachePeriod));
264266
}
265267
String staticPathPattern = this.mvcProperties.getStaticPathPattern();
266268
if (!registry.hasMappingForPattern(staticPathPattern)) {
267-
customizeResourceHandlerRegistration(registry.addResourceHandler(staticPathPattern)
268-
.addResourceLocations(
269-
this.resourceProperties.getStaticLocations())
269+
customizeResourceHandlerRegistration(
270+
registry.addResourceHandler(staticPathPattern)
271+
.addResourceLocations(
272+
this.resourceProperties.getStaticLocations())
270273
.setCachePeriod(cachePeriod));
271274
}
272275
}
273276

274-
private void customizeResourceHandlerRegistration(ResourceHandlerRegistration registration) {
277+
private void customizeResourceHandlerRegistration(
278+
ResourceHandlerRegistration registration) {
275279
if (this.resourceHandlerRegistrationCustomizer != null) {
276280
this.resourceHandlerRegistrationCustomizer.customize(registration);
277281
}
@@ -411,6 +415,7 @@ private ResourceResolver getVersionResourceResolver(
411415
}
412416
return resolver;
413417
}
418+
414419
}
415420

416421
}

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ public void overrideBaselineVersionString() throws Exception {
225225

226226
@Test
227227
public void overrideBaselineVersionNumber() throws Exception {
228-
Map<String, Object> source = Collections.<String, Object>singletonMap("flyway.baseline-version", 1);
229-
this.context.getEnvironment().getPropertySources().addLast(new MapPropertySource("flyway", source));
228+
Map<String, Object> source = Collections
229+
.<String, Object>singletonMap("flyway.baseline-version", 1);
230+
this.context.getEnvironment().getPropertySources()
231+
.addLast(new MapPropertySource("flyway", source));
230232
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
231233
FlywayAutoConfiguration.class,
232234
PropertyPlaceholderAutoConfiguration.class);

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import org.junit.Test;
2020

21-
import static org.hamcrest.CoreMatchers.is;
2221
import static org.hamcrest.CoreMatchers.nullValue;
22+
import static org.hamcrest.Matchers.equalTo;
2323
import static org.junit.Assert.assertThat;
2424

2525
/**
@@ -34,25 +34,25 @@ public class ResourcePropertiesTest {
3434
@Test
3535
public void resourceChainNoCustomization() {
3636
System.out.println(this.properties.getChain().getEnabled());
37-
assertThat(this.properties.getChain().getEnabled(), is(nullValue()));
37+
assertThat(this.properties.getChain().getEnabled(), nullValue());
3838
}
3939

4040
@Test
4141
public void resourceChainStrategyEnabled() {
4242
this.properties.getChain().getStrategy().getFixed().setEnabled(true);
43-
assertThat(this.properties.getChain().getEnabled(), is(true));
43+
assertThat(this.properties.getChain().getEnabled(), equalTo(true));
4444
}
4545

4646
@Test
4747
public void resourceChainEnabled() {
4848
this.properties.getChain().setEnabled(true);
49-
assertThat(this.properties.getChain().getEnabled(), is(true));
49+
assertThat(this.properties.getChain().getEnabled(), equalTo(true));
5050
}
5151

5252
@Test
5353
public void resourceChainDisabled() {
5454
this.properties.getChain().setEnabled(false);
55-
assertThat(this.properties.getChain().getEnabled(), is(false));
55+
assertThat(this.properties.getChain().getEnabled(), equalTo(false));
5656
}
5757

5858
}

spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/FullyExecutableJarTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 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/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 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.
@@ -111,8 +111,8 @@ protected void loadConfiguration(String location, LogFile logFile) {
111111
@Override
112112
public void setLogLevel(String loggerName, LogLevel level) {
113113
Assert.notNull(level, "Level must not be null");
114-
Logger logger = Logger
115-
.getLogger(StringUtils.hasText(loggerName) ? loggerName : "");
114+
String name = (StringUtils.hasText(loggerName) ? loggerName : "");
115+
Logger logger = Logger.getLogger(name);
116116
logger.setLevel(LEVELS.get(level));
117117
}
118118

0 commit comments

Comments
 (0)