diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMeterBinderProvidersConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMeterBinderProvidersConfiguration.java index 38d825a2dd..6cf880182d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMeterBinderProvidersConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMeterBinderProvidersConfiguration.java @@ -37,7 +37,6 @@ import org.springframework.context.annotation.Configuration; * {@link Configuration Auto-configuration} for {@link CacheMeterBinderProvider} beans. * * @author Stephane Nicoll - * @since 2.0.0 */ @Configuration @ConditionalOnClass(MeterBinder.class) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java index 9fc1cfbb3d..c7052582f7 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java @@ -38,7 +38,6 @@ import org.springframework.util.StringUtils; * caches}. * * @author Stephane Nicoll - * @since 2.0.0 */ @Configuration @ConditionalOnBean(CacheMeterBinderProvider.class) @@ -59,8 +58,8 @@ class CacheMetricsRegistrarConfiguration { Collection> binderProviders, Map cacheManagers) { this.registry = registry; - this.binderProviders = binderProviders; this.properties = properties; + this.binderProviders = binderProviders; this.cacheManagers = cacheManagers; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java index 39c9743603..5b47ae6505 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java @@ -39,13 +39,12 @@ public class CacheMetricsConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withUserConfiguration(RegistryConfiguration.class) - .withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class)) + .withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class, CacheAutoConfiguration.class)) .withPropertyValues("management.metrics.use-global-registry=false"); @Test public void autoConfiguredCacheManagerIsInstrumented() { this.contextRunner - .withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class)) .withPropertyValues("spring.cache.type=caffeine", "spring.cache.cache-names=cache1,cache2") .run((context) -> { @@ -60,7 +59,6 @@ public class CacheMetricsConfigurationTests { @Test public void autoConfiguredCacheManagerWithCustomMetricName() { this.contextRunner - .withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class)) .withPropertyValues( "management.metrics.cache.cache-metric-name=custom.name", "spring.cache.type=caffeine", "spring.cache.cache-names=cache1") @@ -76,7 +74,6 @@ public class CacheMetricsConfigurationTests { @Test public void autoConfiguredNonSupportedCacheManagerIsIgnored() { this.contextRunner - .withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class)) .withPropertyValues("spring.cache.type=simple", "spring.cache.cache-names=cache1,cache2") .run((context) -> { @@ -91,7 +88,6 @@ public class CacheMetricsConfigurationTests { @Test public void cacheInstrumentationCanBeDisabled() { this.contextRunner - .withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class)) .withPropertyValues("management.metrics.cache.instrument-cache=false", "spring.cache.type=caffeine", "spring.cache.cache-names=cache1") .run((context) -> { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AnnotationEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AnnotationEndpointDiscoverer.java index 17765cdf1b..0fa1c0ebab 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AnnotationEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AnnotationEndpointDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -63,7 +63,7 @@ import org.springframework.util.StringUtils; public abstract class AnnotationEndpointDiscoverer implements EndpointDiscoverer { - private final Log logger = LogFactory.getLog(getClass()); + private static final Log logger = LogFactory.getLog(AnnotationEndpointDiscoverer.class); private final ApplicationContext applicationContext; @@ -277,10 +277,10 @@ public abstract class AnnotationEndpointDiscoverer catch (ClassCastException ex) { String msg = ex.getMessage(); if (msg == null || msg.startsWith(endpointInfo.getClass().getName())) { - // Possibly a lambda-defined listener which we could not resolve the - // generic event type for - if (this.logger.isDebugEnabled()) { - this.logger.debug("Non-matching info type for filter: " + filter, ex); + // Possibly a lambda-defined EndpointFilter which we could not resolve the + // generic EndpointInfo type for + if (logger.isDebugEnabled()) { + logger.debug("Non-matching EndpointInfo for EndpointFilter: " + filter, ex); } return false; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMetricsRegistrar.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMetricsRegistrar.java index 194a3e0abc..c951c0bdc3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMetricsRegistrar.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMetricsRegistrar.java @@ -39,6 +39,8 @@ import org.springframework.core.ResolvableType; */ public class CacheMetricsRegistrar { + private static final Log logger = LogFactory.getLog(CacheMetricsRegistrar.class); + private final MeterRegistry registry; private final String metricName; @@ -94,12 +96,11 @@ public class CacheMetricsRegistrar { catch (ClassCastException ex) { String msg = ex.getMessage(); if (msg == null || msg.startsWith(cache.getClass().getName())) { - // Possibly a lambda-defined listener which we could not resolve - // the generic event type for - Log logger = LogFactory.getLog(getClass()); + // Possibly a lambda-defined CacheMeterBinderProvider which we could not resolve + // the generic Cache type for if (logger.isDebugEnabled()) { logger.debug( - "Non-matching event type for CacheMeterBinderProvider: " + "Non-matching Cache type for CacheMeterBinderProvider: " + binderProvider, ex); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 14904b6724..1f0673b7ae 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -98,7 +98,7 @@ public class ServerProperties { */ private Duration connectionTimeout; - private Session session = new Session(); + private final Session session = new Session(); @NestedConfigurationProperty private Ssl ssl; @@ -109,7 +109,7 @@ public class ServerProperties { @NestedConfigurationProperty private final Http2 http2 = new Http2(); - private Servlet servlet = new Servlet(); + private final Servlet servlet = new Servlet(); private final Tomcat tomcat = new Tomcat(); @@ -181,10 +181,6 @@ public class ServerProperties { return this.session; } - public void setSession(Session session) { - this.session = session; - } - public Ssl getSsl() { return this.ssl; } @@ -205,10 +201,6 @@ public class ServerProperties { return this.servlet; } - public void setServlet(Servlet servlet) { - this.servlet = servlet; - } - public Tomcat getTomcat() { return this.tomcat; } @@ -242,7 +234,7 @@ public class ServerProperties { private String path = "/"; @NestedConfigurationProperty - private Jsp jsp = new Jsp(); + private final Jsp jsp = new Jsp(); public String getContextPath() { return this.contextPath; @@ -276,10 +268,6 @@ public class ServerProperties { return this.jsp; } - public void setJsp(Jsp jsp) { - this.jsp = jsp; - } - public String getServletMapping() { if (this.path.equals("") || this.path.equals("/")) { return "/"; @@ -359,7 +347,7 @@ public class ServerProperties { */ private File storeDir; - private Cookie cookie = new Cookie(); + private final Cookie cookie = new Cookie(); public Cookie getCookie() { return this.cookie; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizerBeanPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizerBeanPostProcessor.java index 9cbb8bc6f5..3baa50c27e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizerBeanPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizerBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -45,6 +45,8 @@ import org.springframework.util.Assert; public class WebServerFactoryCustomizerBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware { + private static final Log logger = LogFactory.getLog(WebServerFactoryCustomizerBeanPostProcessor.class); + private ListableBeanFactory beanFactory; private List> customizers; @@ -92,8 +94,8 @@ public class WebServerFactoryCustomizerBeanPostProcessor catch (ClassCastException ex) { String msg = ex.getMessage(); if (msg == null || msg.startsWith(webServerFactory.getClass().getName())) { - // Possibly a lambda-defined listener which we could not resolve the - // generic event type for + // Possibly a lambda-defined WebServerFactoryCustomizer which we could not resolve the + // generic WebServerFactory type for logLambdaDebug(customizer, ex); } else { @@ -104,9 +106,8 @@ public class WebServerFactoryCustomizerBeanPostProcessor private void logLambdaDebug(WebServerFactoryCustomizer customizer, ClassCastException ex) { - Log logger = LogFactory.getLog(getClass()); if (logger.isDebugEnabled()) { - logger.debug("Non-matching factory type for customizer: " + customizer, ex); + logger.debug("Non-matching WebServerFactory type for WebServerFactoryCustomizer: " + customizer, ex); } } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java index 65812fdf17..e4a8871acd 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -403,11 +403,10 @@ public class SysVinitLaunchScriptIT { @Override protected Void execute(CopyToContainerCmd command) { - try { - InputStream streamToUpload = new FileInputStream(CompressArchiveUtil - .archiveTARFiles(command.getFile().getParentFile(), - Arrays.asList(command.getFile()), - command.getFile().getName())); + try (InputStream streamToUpload = new FileInputStream(CompressArchiveUtil + .archiveTARFiles(command.getFile().getParentFile(), + Arrays.asList(command.getFile()), + command.getFile().getName()))) { WebTarget webResource = getBaseResource().path("/containers/{id}/archive") .resolveTemplate("id", command.getContainer()); webResource.queryParam("path", ".")