Merge branch '2.0.x'
This commit is contained in:
@@ -44,7 +44,6 @@ public class BeansEndpoint {
|
||||
/**
|
||||
* Creates a new {@code BeansEndpoint} that will describe the beans in the given
|
||||
* {@code context} and all of its ancestors.
|
||||
*
|
||||
* @param context the application context
|
||||
* @see ConfigurableApplicationContext#getParent()
|
||||
*/
|
||||
|
||||
@@ -335,6 +335,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||
}
|
||||
super.serializeAsField(pojo, jgen, provider, writer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,4 +51,5 @@ public final class MissingParametersException extends InvalidEndpointRequestExce
|
||||
public Set<OperationParameter> getMissingParameters() {
|
||||
return this.missingParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ public class EndpointMBean implements DynamicMBean {
|
||||
return this.responseMapper.mapResponse(result);
|
||||
}
|
||||
catch (InvalidEndpointRequestException ex) {
|
||||
throw new ReflectionException(new IllegalArgumentException(
|
||||
ex.getMessage()), ex.getMessage());
|
||||
throw new ReflectionException(new IllegalArgumentException(ex.getMessage()),
|
||||
ex.getMessage());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new MBeanException(translateIfNecessary(ex), ex.getMessage());
|
||||
|
||||
@@ -210,4 +210,5 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ public class EndpointMapping {
|
||||
|
||||
/**
|
||||
* Creates a new {@code EndpointMapping} using the given {@code path}.
|
||||
*
|
||||
* @param path the path
|
||||
*/
|
||||
public EndpointMapping(String path) {
|
||||
|
||||
@@ -44,4 +44,5 @@ class DiscoveredWebEndpoint extends AbstractDiscoveredEndpoint<WebOperation>
|
||||
public String getRootPath() {
|
||||
return this.rootPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -251,6 +251,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
|
||||
|
||||
Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange,
|
||||
Map<String, String> body);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -173,6 +173,7 @@ public class MetricsEndpoint {
|
||||
public Set<String> getNames() {
|
||||
return this.names;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,6 +229,7 @@ public class MetricsEndpoint {
|
||||
public Set<String> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -61,18 +61,17 @@ public class MetricsWebFilter implements WebFilter {
|
||||
private Publisher<Void> filter(ServerWebExchange exchange, Mono<Void> call) {
|
||||
long start = System.nanoTime();
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
return call.doOnSuccess((done) -> success(exchange, start))
|
||||
.doOnError((cause) -> {
|
||||
if (response.isCommitted()) {
|
||||
error(exchange, start, cause);
|
||||
}
|
||||
else {
|
||||
response.beforeCommit(() -> {
|
||||
error(exchange, start, cause);
|
||||
return Mono.empty();
|
||||
});
|
||||
}
|
||||
return call.doOnSuccess((done) -> success(exchange, start)).doOnError((cause) -> {
|
||||
if (response.isCommitted()) {
|
||||
error(exchange, start, cause);
|
||||
}
|
||||
else {
|
||||
response.beforeCommit(() -> {
|
||||
error(exchange, start, cause);
|
||||
return Mono.empty();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void success(ServerWebExchange exchange, long start) {
|
||||
|
||||
@@ -31,7 +31,6 @@ public interface MappingDescriptionProvider {
|
||||
|
||||
/**
|
||||
* Returns the name of the mappings described by this provider.
|
||||
*
|
||||
* @return the name of the mappings
|
||||
*/
|
||||
String getMappingName();
|
||||
|
||||
@@ -40,7 +40,6 @@ public class FilterRegistrationMappingDescription
|
||||
|
||||
/**
|
||||
* Returns the servlet name mappings for the registered filter.
|
||||
*
|
||||
* @return the mappings
|
||||
*/
|
||||
public Collection<String> getServletNameMappings() {
|
||||
@@ -49,7 +48,6 @@ public class FilterRegistrationMappingDescription
|
||||
|
||||
/**
|
||||
* Returns the URL pattern mappings for the registered filter.
|
||||
*
|
||||
* @return the mappings
|
||||
*/
|
||||
public Collection<String> getUrlPatternMappings() {
|
||||
|
||||
@@ -40,7 +40,6 @@ public class RegistrationMappingDescription<T extends Registration> {
|
||||
|
||||
/**
|
||||
* Returns the name of the registered Filter or Servlet.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
@@ -49,7 +48,6 @@ public class RegistrationMappingDescription<T extends Registration> {
|
||||
|
||||
/**
|
||||
* Returns the class name of the registered Filter or Servlet.
|
||||
*
|
||||
* @return the class name
|
||||
*/
|
||||
public String getClassName() {
|
||||
|
||||
@@ -41,7 +41,6 @@ public class ServletRegistrationMappingDescription
|
||||
|
||||
/**
|
||||
* Returns the mappings for the registered servlet.
|
||||
*
|
||||
* @return the mappings
|
||||
*/
|
||||
public Collection<String> getMappings() {
|
||||
|
||||
@@ -81,4 +81,5 @@ public class OperationMethodTests {
|
||||
String example(String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,4 +32,5 @@ class TestJmxOperationResponseMapper implements JmxOperationResponseMapper {
|
||||
public Class<?> mapResponseType(Class<?> responseType) {
|
||||
return responseType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,16 +57,17 @@ public class ControllerEndpointDiscovererTests {
|
||||
|
||||
@Test
|
||||
public void getEndpointsWhenNoEndpointBeansShouldReturnEmptyCollection() {
|
||||
this.contextRunner.withUserConfiguration(EmptyConfiguration.class).run(
|
||||
assertDiscoverer((discoverer) ->
|
||||
assertThat(discoverer.getEndpoints()).isEmpty()));
|
||||
this.contextRunner.withUserConfiguration(EmptyConfiguration.class)
|
||||
.run(assertDiscoverer(
|
||||
(discoverer) -> assertThat(discoverer.getEndpoints()).isEmpty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEndpointsShouldIncludeControllerEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(TestControllerEndpoint.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
assertThat(endpoints).hasSize(1);
|
||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||
assertThat(endpoint.getId()).isEqualTo("testcontroller");
|
||||
@@ -79,10 +80,11 @@ public class ControllerEndpointDiscovererTests {
|
||||
@Test
|
||||
public void getEndpointsShouldDiscoverProxyControllerEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(TestProxyControllerEndpoint.class)
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
ValidationAutoConfiguration.class))
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
assertThat(endpoints).hasSize(1);
|
||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||
assertThat(endpoint.getId()).isEqualTo("testcontroller");
|
||||
@@ -96,7 +98,8 @@ public class ControllerEndpointDiscovererTests {
|
||||
public void getEndpointsShouldIncludeRestControllerEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(TestRestControllerEndpoint.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
assertThat(endpoints).hasSize(1);
|
||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||
assertThat(endpoint.getId()).isEqualTo("testrestcontroller");
|
||||
@@ -108,10 +111,11 @@ public class ControllerEndpointDiscovererTests {
|
||||
@Test
|
||||
public void getEndpointsShouldDiscoverProxyRestControllerEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(TestProxyRestControllerEndpoint.class)
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
ValidationAutoConfiguration.class))
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
assertThat(endpoints).hasSize(1);
|
||||
ExposableControllerEndpoint endpoint = endpoints.iterator().next();
|
||||
assertThat(endpoint.getId()).isEqualTo("testrestcontroller");
|
||||
@@ -125,7 +129,8 @@ public class ControllerEndpointDiscovererTests {
|
||||
public void getEndpointsShouldNotDiscoverRegularEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableControllerEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
List<String> ids = endpoints.stream().map(ExposableEndpoint::getId)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(ids).containsOnly("testcontroller", "testrestcontroller");
|
||||
@@ -137,7 +142,8 @@ public class ControllerEndpointDiscovererTests {
|
||||
this.contextRunner.withUserConfiguration(TestControllerWithOperation.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("ControllerEndpoints must not declare operations");
|
||||
this.thrown.expectMessage(
|
||||
"ControllerEndpoints must not declare operations");
|
||||
discoverer.getEndpoints();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -67,15 +67,16 @@ public class ServletEndpointDiscovererTests {
|
||||
@Test
|
||||
public void getEndpointsWhenNoEndpointBeansShouldReturnEmptyCollection() {
|
||||
this.contextRunner.withUserConfiguration(EmptyConfiguration.class)
|
||||
.run(assertDiscoverer((discoverer)
|
||||
-> assertThat(discoverer.getEndpoints()).isEmpty()));
|
||||
.run(assertDiscoverer(
|
||||
(discoverer) -> assertThat(discoverer.getEndpoints()).isEmpty()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEndpointsShouldIncludeServletEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(TestServletEndpoint.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableServletEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
assertThat(endpoints).hasSize(1);
|
||||
ExposableServletEndpoint endpoint = endpoints.iterator().next();
|
||||
assertThat(endpoint.getId()).isEqualTo("testservlet");
|
||||
@@ -87,9 +88,11 @@ public class ServletEndpointDiscovererTests {
|
||||
@Test
|
||||
public void getEndpointsShouldDiscoverProxyServletEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(TestProxyServletEndpoint.class)
|
||||
.withConfiguration(AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(ValidationAutoConfiguration.class))
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableServletEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
assertThat(endpoints).hasSize(1);
|
||||
ExposableServletEndpoint endpoint = endpoints.iterator().next();
|
||||
assertThat(endpoint.getId()).isEqualTo("testservlet");
|
||||
@@ -102,7 +105,8 @@ public class ServletEndpointDiscovererTests {
|
||||
public void getEndpointsShouldNotDiscoverRegularEndpoints() {
|
||||
this.contextRunner.withUserConfiguration(WithRegularEndpointConfiguration.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
Collection<ExposableServletEndpoint> endpoints = discoverer.getEndpoints();
|
||||
Collection<ExposableServletEndpoint> endpoints = discoverer
|
||||
.getEndpoints();
|
||||
List<String> ids = endpoints.stream().map(ExposableEndpoint::getId)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(ids).containsOnly("testservlet");
|
||||
@@ -114,7 +118,8 @@ public class ServletEndpointDiscovererTests {
|
||||
this.contextRunner.withUserConfiguration(TestServletEndpointWithOperation.class)
|
||||
.run(assertDiscoverer((discoverer) -> {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("ServletEndpoints must not declare operations");
|
||||
this.thrown.expectMessage(
|
||||
"ServletEndpoints must not declare operations");
|
||||
discoverer.getEndpoints();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -27,4 +27,5 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
interface ContextFactory {
|
||||
|
||||
ConfigurableApplicationContext createContext(List<Class<?>> configurationClasses);
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link MetricsWebFilter}
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class MetricsWebFilterTests {
|
||||
|
||||
@@ -331,4 +331,5 @@ public class HttpExchangeTracerTests {
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user