Skip to content

Commit

Permalink
Merge pull request spring-projects#11536 from izeye:polish-20180108
Browse files Browse the repository at this point in the history
* pr/11536:
  Polish
  • Loading branch information
snicoll committed Jan 9, 2018
2 parents 6ea6adb + 0f0c6e0 commit b5a4edc
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* {@link Configuration Auto-configuration} for {@link CacheMeterBinderProvider} beans.
*
* @author Stephane Nicoll
* @since 2.0.0
*/
@Configuration
@ConditionalOnClass(MeterBinder.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* caches}.
*
* @author Stephane Nicoll
* @since 2.0.0
*/
@Configuration
@ConditionalOnBean(CacheMeterBinderProvider.class)
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> {
Expand All @@ -60,7 +59,6 @@ public void autoConfiguredCacheManagerIsInstrumented() {
@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")
Expand All @@ -76,7 +74,6 @@ public void autoConfiguredCacheManagerWithCustomMetricName() {
@Test
public void autoConfiguredNonSupportedCacheManagerIsIgnored() {
this.contextRunner
.withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class))
.withPropertyValues("spring.cache.type=simple",
"spring.cache.cache-names=cache1,cache2")
.run((context) -> {
Expand All @@ -91,7 +88,6 @@ public void autoConfiguredNonSupportedCacheManagerIsIgnored() {
@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) -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -63,7 +63,7 @@
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;

Expand Down Expand Up @@ -277,10 +277,10 @@ private boolean isFilterMatch(EndpointFilter<T> filter,
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
public class CacheMetricsRegistrar {

private static final Log logger = LogFactory.getLog(CacheMetricsRegistrar.class);

private final MeterRegistry registry;

private final String metricName;
Expand Down Expand Up @@ -94,12 +96,11 @@ private MeterBinder getMeterBinder(Cache cache, List<Tag> tags) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -181,10 +181,6 @@ public Session getSession() {
return this.session;
}

public void setSession(Session session) {
this.session = session;
}

public Ssl getSsl() {
return this.ssl;
}
Expand All @@ -205,10 +201,6 @@ public Servlet getServlet() {
return this.servlet;
}

public void setServlet(Servlet servlet) {
this.servlet = servlet;
}

public Tomcat getTomcat() {
return this.tomcat;
}
Expand Down Expand Up @@ -242,7 +234,7 @@ public static class Servlet {
private String path = "/";

@NestedConfigurationProperty
private Jsp jsp = new Jsp();
private final Jsp jsp = new Jsp();

public String getContextPath() {
return this.contextPath;
Expand Down Expand Up @@ -276,10 +268,6 @@ public Jsp getJsp() {
return this.jsp;
}

public void setJsp(Jsp jsp) {
this.jsp = jsp;
}

public String getServletMapping() {
if (this.path.equals("") || this.path.equals("/")) {
return "/";
Expand Down Expand Up @@ -359,7 +347,7 @@ public static class Session {
*/
private File storeDir;

private Cookie cookie = new Cookie();
private final Cookie cookie = new Cookie();

public Cookie getCookie() {
return this.cookie;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -45,6 +45,8 @@
public class WebServerFactoryCustomizerBeanPostProcessor
implements BeanPostProcessor, BeanFactoryAware {

private static final Log logger = LogFactory.getLog(WebServerFactoryCustomizerBeanPostProcessor.class);

private ListableBeanFactory beanFactory;

private List<WebServerFactoryCustomizer<?>> customizers;
Expand Down Expand Up @@ -92,8 +94,8 @@ private void invokeCustomizer(WebServerFactoryCustomizer customizer,
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 {
Expand All @@ -104,9 +106,8 @@ private void invokeCustomizer(WebServerFactoryCustomizer customizer,

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

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -403,11 +403,10 @@ private CopyToContainerCmdExec(WebTarget baseResource,

@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", ".")
Expand Down

0 comments on commit b5a4edc

Please sign in to comment.