From 8d92236eeaca42b6ed7686217a96d19f10100221 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 5 Aug 2015 12:09:23 -0700 Subject: [PATCH] Polish --- .../health/DataSourceHealthIndicator.java | 1 + ...figurationPropertiesAutoConfiguration.java | 3 ++- .../h2/H2ConsoleAutoConfiguration.java | 12 +++++----- .../autoconfigure/web/ServerProperties.java | 22 ++++++++----------- ...soleAutoConfigurationIntegrationTests.java | 1 + .../h2/H2ConsoleAutoConfigurationTests.java | 1 + .../boot/logging/log4j2/ColorConverter.java | 8 +++---- .../log4j2/Log4J2LoggingSystemTests.java | 4 ++-- .../logback/LogbackLoggingSystemTests.java | 4 ++-- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DataSourceHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DataSourceHealthIndicator.java index 138d39ab74..24bebf2c1c 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DataSourceHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DataSourceHealthIndicator.java @@ -213,6 +213,7 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement return super.matchesProduct(product) || product.toLowerCase().startsWith("firebird"); } + }; private final String product; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java index 2aa9a4c916..6e5c77dcf3 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java @@ -23,7 +23,8 @@ import org.springframework.context.annotation.Configuration; /** * {@link EnableAutoConfiguration Auto-configuration} for {@link ConfigurationProperties} - * beans. Automatically binds and validates any bean annotated with {@code @ConfigurationProperties}. + * beans. Automatically binds and validates any bean annotated with + * {@code @ConfigurationProperties}. * * @author Stephane Nicoll * @since 1.3.0 diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java index 944c9d2e65..f78e086b0e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java @@ -55,9 +55,9 @@ public class H2ConsoleAutoConfiguration { @Bean public ServletRegistrationBean h2Console() { - return new ServletRegistrationBean(new WebServlet(), this.properties.getPath() - .endsWith("/") ? this.properties.getPath() + "*" - : this.properties.getPath() + "/*"); + String path = this.properties.getPath(); + String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); + return new ServletRegistrationBean(new WebServlet(), urlMapping); } @Configuration @@ -83,9 +83,9 @@ public class H2ConsoleAutoConfiguration { @Override public void configure(HttpSecurity http) throws Exception { - HttpSecurity h2Console = http.antMatcher(this.console.getPath().endsWith( - "/") ? this.console.getPath() + "**" : this.console.getPath() - + "/**"); + String path = this.console.getPath(); + String antPattern = (path.endsWith("/") ? path + "**" : path + "/**"); + HttpSecurity h2Console = http.antMatcher(antPattern); h2Console.csrf().disable(); h2Console.httpBasic(); h2Console.headers().frameOptions().sameOrigin(); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index b64c6299f8..cfeac131cd 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -777,7 +777,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public boolean isEnabled() { - return enabled; + return this.enabled; } public void setEnabled(boolean enabled) { @@ -785,7 +785,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public String getPattern() { - return pattern; + return this.pattern; } public void setPattern(String pattern) { @@ -793,7 +793,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public String getDirectory() { - return directory; + return this.directory; } public void setDirectory(String directory) { @@ -801,7 +801,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public String getPrefix() { - return prefix; + return this.prefix; } public void setPrefix(String prefix) { @@ -809,7 +809,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public String getSuffix() { - return suffix; + return this.suffix; } public void setSuffix(String suffix) { @@ -888,11 +888,8 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord this.directBuffers = directBuffers; } - /** - * Access log configuration. - */ public Accesslog getAccesslog() { - return accesslog; + return this.accesslog; } /** @@ -969,7 +966,6 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord factory.setAccessLogEnabled(this.accesslog.enabled); } - public static class Accesslog { /** @@ -988,7 +984,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord private File dir = new File("logs"); public boolean isEnabled() { - return enabled; + return this.enabled; } public void setEnabled(boolean enabled) { @@ -996,7 +992,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public String getPattern() { - return pattern; + return this.pattern; } public void setPattern(String pattern) { @@ -1004,7 +1000,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord } public File getDir() { - return dir; + return this.dir; } public void setDir(File dir) { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationIntegrationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationIntegrationTests.java index a7299b2d4b..46bdd9233d 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationIntegrationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationIntegrationTests.java @@ -88,6 +88,7 @@ public class H2ConsoleAutoConfigurationIntegrationTests { public void mockConsole() { } + } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java index 04ad734e90..ca566430f7 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java @@ -109,4 +109,5 @@ public class H2ConsoleAutoConfigurationTests { assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings(), hasItems("/custom/*")); } + } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index 5a5e50c6a7..573e83a0ae 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -89,9 +89,8 @@ public class ColorConverter extends LogEventPatternConverter { */ public static ColorConverter newInstance(Configuration config, String[] options) { if (options.length < 1) { - LOGGER.error( - "Incorrect number of options on style. Expected at least 1, received {}", - options.length); + LOGGER.error("Incorrect number of options on style. " + + "Expected at least 1, received {}", options.length); return null; } if (options[0] == null) { @@ -100,8 +99,7 @@ public class ColorConverter extends LogEventPatternConverter { } PatternParser parser = PatternLayout.createPatternParser(config); List formatters = parser.parse(options[0]); - - AnsiElement element = options.length == 1 ? null : ELEMENTS.get(options[1]); + AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1])); return new ColorConverter(formatters, element); } diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index e5b0145586..fb8fcd7f8f 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -200,8 +200,8 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.beforeInitialize(); this.logger.info("Hidden"); this.loggingSystem.initialize(null, null, null); - this.output - .expect(containsString("Wrapped by: java.lang.RuntimeException: Expected")); + this.output.expect(containsString("Wrapped by: " + + "java.lang.RuntimeException: Expected")); this.logger.warn("Expected exception", new RuntimeException("Expected", new RuntimeException("Cause"))); } diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 8db5822750..ff074e2c40 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -252,8 +252,8 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.beforeInitialize(); this.logger.info("Hidden"); this.loggingSystem.initialize(this.initializationContext, null, null); - this.output - .expect(containsString("Wrapped by: java.lang.RuntimeException: Expected")); + this.output.expect(containsString("Wrapped by: " + + "java.lang.RuntimeException: Expected")); this.logger.warn("Expected exception", new RuntimeException("Expected", new RuntimeException("Cause"))); }