Merge branch '2.0.x'

This commit is contained in:
Phillip Webb
2018-05-04 16:31:46 -07:00
127 changed files with 419 additions and 210 deletions

View File

@@ -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()
*/

View File

@@ -335,6 +335,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
}
super.serializeAsField(pojo, jgen, provider, writer);
}
}
/**

View File

@@ -51,4 +51,5 @@ public final class MissingParametersException extends InvalidEndpointRequestExce
public Set<OperationParameter> getMissingParameters() {
return this.missingParameters;
}
}

View File

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

View File

@@ -210,4 +210,5 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
}
}
}

View File

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

View File

@@ -44,4 +44,5 @@ class DiscoveredWebEndpoint extends AbstractDiscoveredEndpoint<WebOperation>
public String getRootPath() {
return this.rootPath;
}
}

View File

@@ -251,6 +251,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange,
Map<String, String> body);
}
/**

View File

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

View File

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

View File

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

View File

@@ -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;
}
}
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -41,7 +41,6 @@ public class ServletRegistrationMappingDescription
/**
* Returns the mappings for the registered servlet.
*
* @return the mappings
*/
public Collection<String> getMappings() {

View File

@@ -81,4 +81,5 @@ public class OperationMethodTests {
String example(String name) {
return name;
}
}

View File

@@ -32,4 +32,5 @@ class TestJmxOperationResponseMapper implements JmxOperationResponseMapper {
public Class<?> mapResponseType(Class<?> responseType) {
return responseType;
}
}

View File

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

View File

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

View File

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

View File

@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link MetricsWebFilter}
*
* @author Brian Clozel
*/
public class MetricsWebFilterTests {

View File

@@ -331,4 +331,5 @@ public class HttpExchangeTracerTests {
}
return output.toString();
}
}