This commit is contained in:
Phillip Webb
2018-02-08 16:34:49 -08:00
parent a0f4071390
commit 5de46c3186
60 changed files with 141 additions and 123 deletions

View File

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

View File

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

View File

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

View File

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

View File

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