Polish
This commit is contained in:
@@ -40,6 +40,7 @@ import org.springframework.kafka.core.KafkaAdmin;
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for {@link KafkaHealthIndicator}.
|
||||
*
|
||||
* @author Juan Rada
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(KafkaAdmin.class)
|
||||
@@ -55,7 +56,7 @@ public class KafkaHealthIndicatorAutoConfiguration
|
||||
|
||||
private final KafkaHealthIndicatorProperties properties;
|
||||
|
||||
KafkaHealthIndicatorAutoConfiguration(Map<String, KafkaAdmin> admins,
|
||||
public KafkaHealthIndicatorAutoConfiguration(Map<String, KafkaAdmin> admins,
|
||||
KafkaHealthIndicatorProperties properties) {
|
||||
this.admins = admins;
|
||||
this.properties = properties;
|
||||
|
||||
@@ -62,8 +62,8 @@ class MeterRegistryConfigurer {
|
||||
if (registry instanceof CompositeMeterRegistry) {
|
||||
return;
|
||||
}
|
||||
// Customizers must be applied before binders, as they may add custom tags or
|
||||
// alter timer or summary configuration.
|
||||
// Customizers must be applied before binders, as they may add custom
|
||||
// tags or alter timer or summary configuration.
|
||||
customize(registry);
|
||||
addFilters(registry);
|
||||
addBinders(registry);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -53,4 +53,5 @@ public class KafkaHealthIndicatorAutoConfigurationTests {
|
||||
.doesNotHaveBean(KafkaHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.Assert;
|
||||
* {@link HealthIndicator} for Kafka cluster.
|
||||
*
|
||||
* @author Juan Rada
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class KafkaHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
|
||||
@@ -128,11 +128,10 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
|
||||
|
||||
private Object getHandler(HttpServletRequest request) throws Exception {
|
||||
HttpServletRequest wrapper = new UnmodifiableAttributesRequestWrapper(request);
|
||||
for (HandlerMapping handlerMapping : getMappingIntrospector()
|
||||
.getHandlerMappings()) {
|
||||
HandlerExecutionChain chain = handlerMapping.getHandler(wrapper);
|
||||
for (HandlerMapping mapping : getMappingIntrospector().getHandlerMappings()) {
|
||||
HandlerExecutionChain chain = mapping.getHandler(wrapper);
|
||||
if (chain != null) {
|
||||
if (handlerMapping instanceof MatchableHandlerMapping) {
|
||||
if (mapping instanceof MatchableHandlerMapping) {
|
||||
return chain.getHandler();
|
||||
}
|
||||
return null;
|
||||
@@ -294,8 +293,8 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,27 +132,32 @@ public class JerseyWebEndpointIntegrationTests extends
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
filterChain.doFilter(new HttpServletRequestWrapper(request) {
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
|
||||
return new Principal() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Alice";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}, response);
|
||||
filterChain.doFilter(new MockPrincipalWrapper(request), response);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MockPrincipalWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
public MockPrincipalWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return new MockPrincipal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MockPrincipal implements Principal {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Alice";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,21 +152,8 @@ public class WebFluxEndpointIntegrationTests
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange,
|
||||
WebFilterChain chain) {
|
||||
return chain.filter(new ServerWebExchangeDecorator(exchange) {
|
||||
|
||||
@Override
|
||||
public Mono<Principal> getPrincipal() {
|
||||
return Mono.just(new Principal() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Alice";
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
return chain.filter(
|
||||
new MockPrincipalServerWebExchangeDecorator(exchange));
|
||||
}
|
||||
|
||||
};
|
||||
@@ -174,4 +161,27 @@ public class WebFluxEndpointIntegrationTests
|
||||
|
||||
}
|
||||
|
||||
private static class MockPrincipalServerWebExchangeDecorator
|
||||
extends ServerWebExchangeDecorator {
|
||||
|
||||
protected MockPrincipalServerWebExchangeDecorator(ServerWebExchange delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Principal> getPrincipal() {
|
||||
return Mono.just(new MockPrincipal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MockPrincipal implements Principal {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Alice";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -146,27 +146,32 @@ public class MvcWebEndpointIntegrationTests extends
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
filterChain.doFilter(new HttpServletRequestWrapper(request) {
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
|
||||
return new Principal() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Alice";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}, response);
|
||||
filterChain.doFilter(new MockPrincipalWrapper(request), response);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MockPrincipalWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
public MockPrincipalWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return new MockPrincipal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MockPrincipal implements Principal {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Alice";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -6152,6 +6152,8 @@ NOTE: While Spring's test framework caches application contexts between tests an
|
||||
a context for tests sharing the same configuration, the use of `@MockBean` or `@SpyBean`
|
||||
influences the cache key, which will most likely increase the number of contexts.
|
||||
|
||||
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]]
|
||||
==== Auto-configured Tests
|
||||
Spring Boot's auto-configuration system works well for applications but can sometimes be
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -127,27 +127,25 @@ class JavaBeanBinder implements BeanBinder {
|
||||
int parameterCount = method.getParameterCount();
|
||||
if (name.startsWith("get") && parameterCount == 0) {
|
||||
name = Introspector.decapitalize(name.substring(3));
|
||||
this.properties
|
||||
.computeIfAbsent(name,
|
||||
(n) -> new BeanProperty(n, this.resolvableType))
|
||||
this.properties.computeIfAbsent(name, this::getBeanProperty)
|
||||
.addGetter(method);
|
||||
}
|
||||
else if (name.startsWith("is") && parameterCount == 0) {
|
||||
name = Introspector.decapitalize(name.substring(2));
|
||||
this.properties
|
||||
.computeIfAbsent(name,
|
||||
(n) -> new BeanProperty(n, this.resolvableType))
|
||||
this.properties.computeIfAbsent(name, this::getBeanProperty)
|
||||
.addGetter(method);
|
||||
}
|
||||
else if (name.startsWith("set") && parameterCount == 1) {
|
||||
name = Introspector.decapitalize(name.substring(3));
|
||||
this.properties
|
||||
.computeIfAbsent(name,
|
||||
(n) -> new BeanProperty(n, this.resolvableType))
|
||||
this.properties.computeIfAbsent(name, this::getBeanProperty)
|
||||
.addSetter(method);
|
||||
}
|
||||
}
|
||||
|
||||
private BeanProperty getBeanProperty(String name) {
|
||||
return new BeanProperty(name, this.resolvableType);
|
||||
}
|
||||
|
||||
private void addField(Field field) {
|
||||
BeanProperty property = this.properties.get(field.getName());
|
||||
if (property != null) {
|
||||
|
||||
@@ -107,8 +107,7 @@ public class ApplicationHome {
|
||||
try {
|
||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
for (int i = stackTrace.length - 1; i >= 0; i--) {
|
||||
StackTraceElement element = stackTrace[i];
|
||||
if (element.getClassName().startsWith("org.junit.")) {
|
||||
if (stackTrace[i].getClassName().startsWith("org.junit.")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ public class BinderTests {
|
||||
public void setBar(T bar) {
|
||||
this.bar = bar;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user