Merge pull request #11536 from izeye:polish-20180108

* pr/11536:
  Polish
pull/11534/merge
Stephane Nicoll 7 years ago
commit b5a4edc9e8

@ -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)

@ -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<CacheMeterBinderProvider<?>> binderProviders,
Map<String, CacheManager> cacheManagers) {
this.registry = registry;
this.binderProviders = binderProviders;
this.properties = properties;
this.binderProviders = binderProviders;
this.cacheManagers = cacheManagers;
}

@ -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) -> {

@ -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<K, T extends Operation>
implements EndpointDiscoverer<T> {
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<K, T extends Operation>
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;
}

@ -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);
}

@ -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;

@ -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<WebServerFactoryCustomizer<?>> 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);
}
}

@ -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
try (InputStream streamToUpload = new FileInputStream(CompressArchiveUtil
.archiveTARFiles(command.getFile().getParentFile(),
Arrays.asList(command.getFile()),
command.getFile().getName()));
command.getFile().getName()))) {
WebTarget webResource = getBaseResource().path("/containers/{id}/archive")
.resolveTemplate("id", command.getContainer());
webResource.queryParam("path", ".")

Loading…
Cancel
Save