Skip to content

Commit b5a4edc

Browse files
committed
Merge pull request #11536 from izeye:polish-20180108
* pr/11536: Polish
2 parents 6ea6adb + 0f0c6e0 commit b5a4edc

File tree

8 files changed

+28
-45
lines changed

8 files changed

+28
-45
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMeterBinderProvidersConfiguration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
* {@link Configuration Auto-configuration} for {@link CacheMeterBinderProvider} beans.
3838
*
3939
* @author Stephane Nicoll
40-
* @since 2.0.0
4140
*/
4241
@Configuration
4342
@ConditionalOnClass(MeterBinder.class)

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
* caches}.
3939
*
4040
* @author Stephane Nicoll
41-
* @since 2.0.0
4241
*/
4342
@Configuration
4443
@ConditionalOnBean(CacheMeterBinderProvider.class)
@@ -59,8 +58,8 @@ class CacheMetricsRegistrarConfiguration {
5958
Collection<CacheMeterBinderProvider<?>> binderProviders,
6059
Map<String, CacheManager> cacheManagers) {
6160
this.registry = registry;
62-
this.binderProviders = binderProviders;
6361
this.properties = properties;
62+
this.binderProviders = binderProviders;
6463
this.cacheManagers = cacheManagers;
6564
}
6665

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ public class CacheMetricsConfigurationTests {
3939

4040
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
4141
.withUserConfiguration(RegistryConfiguration.class)
42-
.withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class))
42+
.withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class, CacheAutoConfiguration.class))
4343
.withPropertyValues("management.metrics.use-global-registry=false");
4444

4545
@Test
4646
public void autoConfiguredCacheManagerIsInstrumented() {
4747
this.contextRunner
48-
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class))
4948
.withPropertyValues("spring.cache.type=caffeine",
5049
"spring.cache.cache-names=cache1,cache2")
5150
.run((context) -> {
@@ -60,7 +59,6 @@ public void autoConfiguredCacheManagerIsInstrumented() {
6059
@Test
6160
public void autoConfiguredCacheManagerWithCustomMetricName() {
6261
this.contextRunner
63-
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class))
6462
.withPropertyValues(
6563
"management.metrics.cache.cache-metric-name=custom.name",
6664
"spring.cache.type=caffeine", "spring.cache.cache-names=cache1")
@@ -76,7 +74,6 @@ public void autoConfiguredCacheManagerWithCustomMetricName() {
7674
@Test
7775
public void autoConfiguredNonSupportedCacheManagerIsIgnored() {
7876
this.contextRunner
79-
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class))
8077
.withPropertyValues("spring.cache.type=simple",
8178
"spring.cache.cache-names=cache1,cache2")
8279
.run((context) -> {
@@ -91,7 +88,6 @@ public void autoConfiguredNonSupportedCacheManagerIsIgnored() {
9188
@Test
9289
public void cacheInstrumentationCanBeDisabled() {
9390
this.contextRunner
94-
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class))
9591
.withPropertyValues("management.metrics.cache.instrument-cache=false",
9692
"spring.cache.type=caffeine", "spring.cache.cache-names=cache1")
9793
.run((context) -> {

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AnnotationEndpointDiscoverer.java

Lines changed: 6 additions & 6 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.
@@ -63,7 +63,7 @@
6363
public abstract class AnnotationEndpointDiscoverer<K, T extends Operation>
6464
implements EndpointDiscoverer<T> {
6565

66-
private final Log logger = LogFactory.getLog(getClass());
66+
private static final Log logger = LogFactory.getLog(AnnotationEndpointDiscoverer.class);
6767

6868
private final ApplicationContext applicationContext;
6969

@@ -277,10 +277,10 @@ private boolean isFilterMatch(EndpointFilter<T> filter,
277277
catch (ClassCastException ex) {
278278
String msg = ex.getMessage();
279279
if (msg == null || msg.startsWith(endpointInfo.getClass().getName())) {
280-
// Possibly a lambda-defined listener which we could not resolve the
281-
// generic event type for
282-
if (this.logger.isDebugEnabled()) {
283-
this.logger.debug("Non-matching info type for filter: " + filter, ex);
280+
// Possibly a lambda-defined EndpointFilter which we could not resolve the
281+
// generic EndpointInfo type for
282+
if (logger.isDebugEnabled()) {
283+
logger.debug("Non-matching EndpointInfo for EndpointFilter: " + filter, ex);
284284
}
285285
return false;
286286
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMetricsRegistrar.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
*/
4040
public class CacheMetricsRegistrar {
4141

42+
private static final Log logger = LogFactory.getLog(CacheMetricsRegistrar.class);
43+
4244
private final MeterRegistry registry;
4345

4446
private final String metricName;
@@ -94,12 +96,11 @@ private MeterBinder getMeterBinder(Cache cache, List<Tag> tags) {
9496
catch (ClassCastException ex) {
9597
String msg = ex.getMessage();
9698
if (msg == null || msg.startsWith(cache.getClass().getName())) {
97-
// Possibly a lambda-defined listener which we could not resolve
98-
// the generic event type for
99-
Log logger = LogFactory.getLog(getClass());
99+
// Possibly a lambda-defined CacheMeterBinderProvider which we could not resolve
100+
// the generic Cache type for
100101
if (logger.isDebugEnabled()) {
101102
logger.debug(
102-
"Non-matching event type for CacheMeterBinderProvider: "
103+
"Non-matching Cache type for CacheMeterBinderProvider: "
103104
+ binderProvider,
104105
ex);
105106
}

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public class ServerProperties {
9898
*/
9999
private Duration connectionTimeout;
100100

101-
private Session session = new Session();
101+
private final Session session = new Session();
102102

103103
@NestedConfigurationProperty
104104
private Ssl ssl;
@@ -109,7 +109,7 @@ public class ServerProperties {
109109
@NestedConfigurationProperty
110110
private final Http2 http2 = new Http2();
111111

112-
private Servlet servlet = new Servlet();
112+
private final Servlet servlet = new Servlet();
113113

114114
private final Tomcat tomcat = new Tomcat();
115115

@@ -181,10 +181,6 @@ public Session getSession() {
181181
return this.session;
182182
}
183183

184-
public void setSession(Session session) {
185-
this.session = session;
186-
}
187-
188184
public Ssl getSsl() {
189185
return this.ssl;
190186
}
@@ -205,10 +201,6 @@ public Servlet getServlet() {
205201
return this.servlet;
206202
}
207203

208-
public void setServlet(Servlet servlet) {
209-
this.servlet = servlet;
210-
}
211-
212204
public Tomcat getTomcat() {
213205
return this.tomcat;
214206
}
@@ -242,7 +234,7 @@ public static class Servlet {
242234
private String path = "/";
243235

244236
@NestedConfigurationProperty
245-
private Jsp jsp = new Jsp();
237+
private final Jsp jsp = new Jsp();
246238

247239
public String getContextPath() {
248240
return this.contextPath;
@@ -276,10 +268,6 @@ public Jsp getJsp() {
276268
return this.jsp;
277269
}
278270

279-
public void setJsp(Jsp jsp) {
280-
this.jsp = jsp;
281-
}
282-
283271
public String getServletMapping() {
284272
if (this.path.equals("") || this.path.equals("/")) {
285273
return "/";
@@ -359,7 +347,7 @@ public static class Session {
359347
*/
360348
private File storeDir;
361349

362-
private Cookie cookie = new Cookie();
350+
private final Cookie cookie = new Cookie();
363351

364352
public Cookie getCookie() {
365353
return this.cookie;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizerBeanPostProcessor.java

Lines changed: 6 additions & 5 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.
@@ -45,6 +45,8 @@
4545
public class WebServerFactoryCustomizerBeanPostProcessor
4646
implements BeanPostProcessor, BeanFactoryAware {
4747

48+
private static final Log logger = LogFactory.getLog(WebServerFactoryCustomizerBeanPostProcessor.class);
49+
4850
private ListableBeanFactory beanFactory;
4951

5052
private List<WebServerFactoryCustomizer<?>> customizers;
@@ -92,8 +94,8 @@ private void invokeCustomizer(WebServerFactoryCustomizer customizer,
9294
catch (ClassCastException ex) {
9395
String msg = ex.getMessage();
9496
if (msg == null || msg.startsWith(webServerFactory.getClass().getName())) {
95-
// Possibly a lambda-defined listener which we could not resolve the
96-
// generic event type for
97+
// Possibly a lambda-defined WebServerFactoryCustomizer which we could not resolve the
98+
// generic WebServerFactory type for
9799
logLambdaDebug(customizer, ex);
98100
}
99101
else {
@@ -104,9 +106,8 @@ private void invokeCustomizer(WebServerFactoryCustomizer customizer,
104106

105107
private void logLambdaDebug(WebServerFactoryCustomizer<?> customizer,
106108
ClassCastException ex) {
107-
Log logger = LogFactory.getLog(getClass());
108109
if (logger.isDebugEnabled()) {
109-
logger.debug("Non-matching factory type for customizer: " + customizer, ex);
110+
logger.debug("Non-matching WebServerFactory type for WebServerFactoryCustomizer: " + customizer, ex);
110111
}
111112
}
112113

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java

Lines changed: 5 additions & 6 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.
@@ -403,11 +403,10 @@ private CopyToContainerCmdExec(WebTarget baseResource,
403403

404404
@Override
405405
protected Void execute(CopyToContainerCmd command) {
406-
try {
407-
InputStream streamToUpload = new FileInputStream(CompressArchiveUtil
408-
.archiveTARFiles(command.getFile().getParentFile(),
409-
Arrays.asList(command.getFile()),
410-
command.getFile().getName()));
406+
try (InputStream streamToUpload = new FileInputStream(CompressArchiveUtil
407+
.archiveTARFiles(command.getFile().getParentFile(),
408+
Arrays.asList(command.getFile()),
409+
command.getFile().getName()))) {
411410
WebTarget webResource = getBaseResource().path("/containers/{id}/archive")
412411
.resolveTemplate("id", command.getContainer());
413412
webResource.queryParam("path", ".")

0 commit comments

Comments
 (0)