diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java index 216b06fbd9b..c13cd3550e5 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java @@ -100,4 +100,5 @@ public class AuthenticationAuditListenerTests { assertThat(auditApplicationEvent.getValue().getAuditEvent().getData(), hasEntry("details", details)); } + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 699092f22a5..ad2e94e51f4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -183,26 +183,27 @@ public class FlywayAutoConfiguration { private static class StringOrNumberToMigrationVersionConverter implements GenericConverter { - private static final Set CONVERTIBLE_PAIRS = createConvertiblePairs(); + private static final Set CONVERTIBLE_TYPES; + + static { + Set types = new HashSet(2); + types.add(new ConvertiblePair(String.class, MigrationVersion.class)); + types.add(new ConvertiblePair(Number.class, MigrationVersion.class)); + CONVERTIBLE_TYPES = Collections.unmodifiableSet(types); + } @Override public Set getConvertibleTypes() { - return CONVERTIBLE_PAIRS; + return CONVERTIBLE_TYPES; } @Override - public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { + public Object convert(Object source, TypeDescriptor sourceType, + TypeDescriptor targetType) { String value = ObjectUtils.nullSafeToString(source); return MigrationVersion.fromVersion(value); } - private static Set createConvertiblePairs() { - Set convertiblePairs = new HashSet(2); - convertiblePairs.add(new ConvertiblePair(String.class, MigrationVersion.class)); - convertiblePairs.add(new ConvertiblePair(Number.class, MigrationVersion.class)); - return Collections.unmodifiableSet(convertiblePairs); - } - } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java index 9446c3bc200..d75a2d10e9c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ConditionalOnEnabledResourceChain.java @@ -26,8 +26,8 @@ import org.springframework.context.annotation.Conditional; /** * {@link Conditional} that checks whether or not the Spring resource handling chain is - * enabled. Matches if {@link ResourceProperties.Chain#getEnabled()} is {@code true} or - * if {@code webjars-locator} is on the classpath. + * enabled. Matches if {@link ResourceProperties.Chain#getEnabled()} is {@code true} or if + * {@code webjars-locator} is on the classpath. * * @author Stephane Nicoll * @since 1.3.0 diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java index 34ac6198bbb..7a05d1b117f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/OnEnabledResourceChainCondition.java @@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils; */ class OnEnabledResourceChainCondition extends SpringBootCondition { - public static final String WEBJAR_ASSERT_LOCATOR = "org.webjars.WebJarAssetLocator"; + private static final String WEBJAR_ASSERT_LOCATOR = "org.webjars.WebJarAssetLocator"; @Override public ConditionOutcome getMatchOutcome(ConditionContext context, @@ -46,8 +46,8 @@ class OnEnabledResourceChainCondition extends SpringBootCondition { binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources())); Boolean match = properties.getChain().getEnabled(); if (match == null) { - boolean webJarsLocatorPresent = ClassUtils.isPresent( - WEBJAR_ASSERT_LOCATOR, getClass().getClassLoader()); + boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR, + getClass().getClassLoader()); return new ConditionOutcome(webJarsLocatorPresent, "Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is " + (webJarsLocatorPresent ? "present" : "absent")); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java index b0b7b5cb2a3..a86bcc0b730 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,11 +175,10 @@ public class ResourceProperties implements ResourceLoaderAware { /** * Return whether the resource chain is enabled. Return {@code null} if no * specific settings are present. - * @return whether the resource chain is enabled or {@code null} if no - * specified settings are present. + * @return whether the resource chain is enabled or {@code null} if no specified + * settings are present. */ public Boolean getEnabled() { - // Check if at least one of the available strategy has been enabled Boolean strategyEnabled = getStrategy().getFixed().isEnabled() || getStrategy().getContent().isEnabled(); return (strategyEnabled ? Boolean.TRUE : this.enabled); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index cd8a7a2ea5d..b70565a09c3 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -258,20 +258,24 @@ public class WebMvcAutoConfiguration { } Integer cachePeriod = this.resourceProperties.getCachePeriod(); if (!registry.hasMappingForPattern("/webjars/**")) { - customizeResourceHandlerRegistration(registry.addResourceHandler("/webjars/**") - .addResourceLocations("classpath:/META-INF/resources/webjars/") + customizeResourceHandlerRegistration( + registry.addResourceHandler("/webjars/**") + .addResourceLocations( + "classpath:/META-INF/resources/webjars/") .setCachePeriod(cachePeriod)); } String staticPathPattern = this.mvcProperties.getStaticPathPattern(); if (!registry.hasMappingForPattern(staticPathPattern)) { - customizeResourceHandlerRegistration(registry.addResourceHandler(staticPathPattern) - .addResourceLocations( - this.resourceProperties.getStaticLocations()) + customizeResourceHandlerRegistration( + registry.addResourceHandler(staticPathPattern) + .addResourceLocations( + this.resourceProperties.getStaticLocations()) .setCachePeriod(cachePeriod)); } } - private void customizeResourceHandlerRegistration(ResourceHandlerRegistration registration) { + private void customizeResourceHandlerRegistration( + ResourceHandlerRegistration registration) { if (this.resourceHandlerRegistrationCustomizer != null) { this.resourceHandlerRegistrationCustomizer.customize(registration); } @@ -411,6 +415,7 @@ public class WebMvcAutoConfiguration { } return resolver; } + } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index 37da00e6ca1..729af83a6a3 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -225,8 +225,10 @@ public class FlywayAutoConfigurationTests { @Test public void overrideBaselineVersionNumber() throws Exception { - Map source = Collections.singletonMap("flyway.baseline-version", 1); - this.context.getEnvironment().getPropertySources().addLast(new MapPropertySource("flyway", source)); + Map source = Collections + .singletonMap("flyway.baseline-version", 1); + this.context.getEnvironment().getPropertySources() + .addLast(new MapPropertySource("flyway", source)); registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTest.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTest.java index 4a288ab182a..cbe40826125 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTest.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTest.java @@ -18,8 +18,8 @@ package org.springframework.boot.autoconfigure.web; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; /** @@ -34,25 +34,25 @@ public class ResourcePropertiesTest { @Test public void resourceChainNoCustomization() { System.out.println(this.properties.getChain().getEnabled()); - assertThat(this.properties.getChain().getEnabled(), is(nullValue())); + assertThat(this.properties.getChain().getEnabled(), nullValue()); } @Test public void resourceChainStrategyEnabled() { this.properties.getChain().getStrategy().getFixed().setEnabled(true); - assertThat(this.properties.getChain().getEnabled(), is(true)); + assertThat(this.properties.getChain().getEnabled(), equalTo(true)); } @Test public void resourceChainEnabled() { this.properties.getChain().setEnabled(true); - assertThat(this.properties.getChain().getEnabled(), is(true)); + assertThat(this.properties.getChain().getEnabled(), equalTo(true)); } @Test public void resourceChainDisabled() { this.properties.getChain().setEnabled(false); - assertThat(this.properties.getChain().getEnabled(), is(false)); + assertThat(this.properties.getChain().getEnabled(), equalTo(false)); } } diff --git a/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/FullyExecutableJarTests.java b/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/FullyExecutableJarTests.java index 86704f2012c..4396ea0c7a7 100644 --- a/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/FullyExecutableJarTests.java +++ b/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/FullyExecutableJarTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java index 8326ceb67b4..5730ad4d984 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,8 +111,8 @@ public class JavaLoggingSystem extends AbstractLoggingSystem { @Override public void setLogLevel(String loggerName, LogLevel level) { Assert.notNull(level, "Level must not be null"); - Logger logger = Logger - .getLogger(StringUtils.hasText(loggerName) ? loggerName : ""); + String name = (StringUtils.hasText(loggerName) ? loggerName : ""); + Logger logger = Logger.getLogger(name); logger.setLevel(LEVELS.get(level)); } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java index 60f56ed7bcb..625f439c7b0 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -208,10 +208,9 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem { return getLoggerContext().getConfiguration().getLoggerConfig(""); } - private LoggerConfig getLoggerConfig(String loggerName) { - loggerName = StringUtils.hasText(loggerName) ? loggerName - : LogManager.ROOT_LOGGER_NAME; - return getLoggerContext().getConfiguration().getLoggers().get(loggerName); + private LoggerConfig getLoggerConfig(String name) { + name = (StringUtils.hasText(name) ? name : LogManager.ROOT_LOGGER_NAME); + return getLoggerContext().getConfiguration().getLoggers().get(name); } private LoggerContext getLoggerContext() { diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/ConverterBindingTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/ConverterBindingTests.java index 61a5bbd9409..7d4177e004f 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/ConverterBindingTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/ConverterBindingTests.java @@ -49,7 +49,7 @@ import static org.junit.Assert.assertThat; */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(TestConfig.class) -@IntegrationTest({"foo=one", "bar=two"}) +@IntegrationTest({ "foo=one", "bar=two" }) public class ConverterBindingTests { @Value("${foo:}") @@ -88,11 +88,13 @@ public class ConverterBindingTests { return new GenericConverter() { @Override public Set getConvertibleTypes() { - return Collections.singleton(new ConvertiblePair(String.class, Bar.class)); + return Collections + .singleton(new ConvertiblePair(String.class, Bar.class)); } @Override - public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { + public Object convert(Object source, TypeDescriptor sourceType, + TypeDescriptor targetType) { return new Bar((String) source); } }; @@ -112,6 +114,7 @@ public class ConverterBindingTests { public Foo(String name) { this.name = name; } + } public static class Bar { @@ -121,6 +124,7 @@ public class ConverterBindingTests { public Bar(String name) { this.name = name; } + } @ConfigurationProperties @@ -145,6 +149,7 @@ public class ConverterBindingTests { public void setBar(Bar bar) { this.bar = bar; } + } }