From 18319ac2768688cb4ae22987622e64bf5325f432 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sun, 14 Oct 2018 13:40:19 -0700 Subject: [PATCH] Remove deprecated Endpoint ID methods See gh-14773 --- .../web/MappingWebEndpointPathMapper.java | 6 --- ...loudFoundryWebEndpointDiscovererTests.java | 2 +- .../endpoint/AbstractExposableEndpoint.java | 19 +-------- .../actuate/endpoint/ExposableEndpoint.java | 13 +------ .../AbstractDiscoveredEndpoint.java | 18 --------- .../annotation/EndpointDiscoverer.java | 39 +------------------ .../invoke/OperationInvokerAdvisor.java | 20 +--------- .../cache/CachingOperationInvokerAdvisor.java | 7 ---- .../jmx/annotation/JmxEndpointDiscoverer.java | 15 ------- .../endpoint/web/PathMappedEndpoints.java | 39 ------------------- .../boot/actuate/endpoint/web/PathMapper.java | 29 +------------- .../ControllerEndpointDiscoverer.java | 15 ------- .../annotation/ServletEndpointDiscoverer.java | 15 ------- .../web/annotation/WebEndpointDiscoverer.java | 15 ------- .../DiscoveredOperationsFactoryTests.java | 7 ---- .../annotation/EndpointDiscovererTests.java | 21 ++-------- .../jmx/TestExposableJmxEndpoint.java | 6 ++- .../WebEndpointDiscovererTests.java | 27 ++++++------- 18 files changed, 31 insertions(+), 282 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapper.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapper.java index 9bed06f81b..e8cf0147d9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapper.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/MappingWebEndpointPathMapper.java @@ -38,12 +38,6 @@ class MappingWebEndpointPathMapper implements PathMapper { .put(EndpointId.fromPropertyValue(id), path)); } - @Override - @Deprecated - public String getRootPath(String endpointId) { - return getRootPath(EndpointId.of(endpointId)); - } - @Override public String getRootPath(EndpointId endpointId) { return this.pathMapping.getOrDefault(endpointId, endpointId.toLowerCaseString()); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java index 2ddc0457e2..521f957b57 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java @@ -80,7 +80,7 @@ public class CloudFoundryWebEndpointDiscovererTests { private void load(Class configuration, Consumer consumer) { - this.load((id) -> null, (id) -> id, configuration, consumer); + this.load((id) -> null, (id) -> id.toString(), configuration, consumer); } private void load(Function timeToLive, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java index e2e762ab75..cda91f3e74 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java @@ -44,21 +44,6 @@ public abstract class AbstractExposableEndpoint * @param id the endpoint id * @param enabledByDefault if the endpoint is enabled by default * @param operations the endpoint operations - * @deprecated since 2.0.6 in favor of - * {@link #AbstractExposableEndpoint(EndpointId, boolean, Collection)} - */ - @Deprecated - public AbstractExposableEndpoint(String id, boolean enabledByDefault, - Collection operations) { - this(EndpointId.of(id), enabledByDefault, operations); - } - - /** - * Create a new {@link AbstractExposableEndpoint} instance. - * @param id the endpoint id - * @param enabledByDefault if the endpoint is enabled by default - * @param operations the endpoint operations - * @since 2.0.6 */ public AbstractExposableEndpoint(EndpointId id, boolean enabledByDefault, Collection operations) { @@ -70,8 +55,8 @@ public abstract class AbstractExposableEndpoint } @Override - public String getId() { - return this.id.toString(); + public EndpointId getEndpointId() { + return this.id; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ExposableEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ExposableEndpoint.java index f9984ff20e..c9d27a8db9 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ExposableEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ExposableEndpoint.java @@ -28,22 +28,11 @@ import java.util.Collection; */ public interface ExposableEndpoint { - /** - * Returns the id of the endpoint. - * @return the id - * @deprecated since 2.0.6 in favor of {@link #getEndpointId()} - */ - @Deprecated - String getId(); - /** * Return the endpoint ID. * @return the endpoint ID - * @since 2.0.6 */ - default EndpointId getEndpointId() { - return EndpointId.of(getId()); - } + EndpointId getEndpointId(); /** * Returns if the endpoint is enabled by default. diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java index 6c582f9fe0..df38b4f9b6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java @@ -47,24 +47,6 @@ public abstract class AbstractDiscoveredEndpoint * @param id the ID of the endpoint * @param enabledByDefault if the endpoint is enabled by default * @param operations the endpoint operations - * @deprecated since 2.0.6 in favor of - * {@link #AbstractDiscoveredEndpoint(EndpointDiscoverer, Object, EndpointId, boolean, Collection)} - */ - @Deprecated - public AbstractDiscoveredEndpoint(EndpointDiscoverer discoverer, - Object endpointBean, String id, boolean enabledByDefault, - Collection operations) { - this(discoverer, endpointBean, EndpointId.of(id), enabledByDefault, operations); - } - - /** - * Create a new {@link AbstractDiscoveredEndpoint} instance. - * @param discoverer the discoverer that discovered the endpoint - * @param endpointBean the primary source bean - * @param id the ID of the endpoint - * @param enabledByDefault if the endpoint is enabled by default - * @param operations the endpoint operations - * @since 2.0.6 */ public AbstractDiscoveredEndpoint(EndpointDiscoverer discoverer, Object endpointBean, EndpointId id, boolean enabledByDefault, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index 92d59d3d03..35c6a8151e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -340,26 +340,8 @@ public abstract class EndpointDiscoverer, O exten * @param enabledByDefault if the endpoint is enabled by default * @param operations the endpoint operations * @return a created endpoint (a {@link DiscoveredEndpoint} is recommended) - * @since 2.0.6 */ - protected E createEndpoint(Object endpointBean, EndpointId id, - boolean enabledByDefault, Collection operations) { - return createEndpoint(endpointBean, (id != null) ? id.toString() : null, - enabledByDefault, operations); - } - - /** - * Factory method called to create the {@link ExposableEndpoint endpoint}. - * @param endpointBean the source endpoint bean - * @param id the ID of the endpoint - * @param enabledByDefault if the endpoint is enabled by default - * @param operations the endpoint operations - * @return a created endpoint (a {@link DiscoveredEndpoint} is recommended) - * @deprecated Since 2.0.6 in favor of - * {@link #createEndpoint(Object, EndpointId, boolean, Collection)} - */ - @Deprecated - protected abstract E createEndpoint(Object endpointBean, String id, + protected abstract E createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, Collection operations); /** @@ -368,25 +350,8 @@ public abstract class EndpointDiscoverer, O exten * @param operationMethod the operation method * @param invoker the invoker to use * @return a created operation - * @since 2.0.6 - */ - protected O createOperation(EndpointId endpointId, - DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { - return createOperation((endpointId != null) ? endpointId.toString() : null, - operationMethod, invoker); - } - - /** - * Factory method to create an {@link Operation endpoint operation}. - * @param endpointId the endpoint id - * @param operationMethod the operation method - * @param invoker the invoker to use - * @return a created operation - * @deprecated since 2.0.6 in favor of - * {@link #createOperation(EndpointId, DiscoveredOperationMethod, OperationInvoker)} */ - @Deprecated - protected abstract O createOperation(String endpointId, + protected abstract O createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker); /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/OperationInvokerAdvisor.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/OperationInvokerAdvisor.java index ab0d0edd72..ff45682fd8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/OperationInvokerAdvisor.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoke/OperationInvokerAdvisor.java @@ -35,26 +35,8 @@ public interface OperationInvokerAdvisor { * @param parameters the operation parameters * @param invoker the invoker to advise * @return an potentially new operation invoker with support for additional features - * @since 2.0.6 */ - default OperationInvoker apply(EndpointId endpointId, OperationType operationType, - OperationParameters parameters, OperationInvoker invoker) { - return apply((endpointId != null) ? endpointId.toString() : null, operationType, - parameters, invoker); - } - - /** - * Apply additional functionality to the given invoker. - * @param endpointId the endpoint ID - * @param operationType the operation type - * @param parameters the operation parameters - * @param invoker the invoker to advise - * @return an potentially new operation invoker with support for additional features - * @deprecated since 2.0.6 in favor of - * {@link #apply(EndpointId, OperationType, OperationParameters, OperationInvoker)} - */ - @Deprecated - OperationInvoker apply(String endpointId, OperationType operationType, + OperationInvoker apply(EndpointId endpointId, OperationType operationType, OperationParameters parameters, OperationInvoker invoker); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisor.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisor.java index ab97e2e745..1813a74c6f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisor.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerAdvisor.java @@ -41,13 +41,6 @@ public class CachingOperationInvokerAdvisor implements OperationInvokerAdvisor { this.endpointIdTimeToLive = endpointIdTimeToLive; } - @Override - @Deprecated - public OperationInvoker apply(String endpointId, OperationType operationType, - OperationParameters parameters, OperationInvoker invoker) { - return apply(EndpointId.of(endpointId), operationType, parameters, invoker); - } - @Override public OperationInvoker apply(EndpointId endpointId, OperationType operationType, OperationParameters parameters, OperationInvoker invoker) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxEndpointDiscoverer.java index 7037475ce7..accf002bbc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxEndpointDiscoverer.java @@ -54,14 +54,6 @@ public class JmxEndpointDiscoverer super(applicationContext, parameterValueMapper, invokerAdvisors, filters); } - @Override - @Deprecated - protected ExposableJmxEndpoint createEndpoint(Object endpointBean, String id, - boolean enabledByDefault, Collection operations) { - return createEndpoint(endpointBean, EndpointId.of(id), enabledByDefault, - operations); - } - @Override protected ExposableJmxEndpoint createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, Collection operations) { @@ -69,13 +61,6 @@ public class JmxEndpointDiscoverer operations); } - @Override - @Deprecated - protected JmxOperation createOperation(String endpointId, - DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { - return createOperation(EndpointId.of(endpointId), operationMethod, invoker); - } - @Override protected JmxOperation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java index a3392e87be..9c728660ab 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java @@ -90,19 +90,6 @@ public class PathMappedEndpoints implements Iterable { * endpoint cannot be found. * @param endpointId the endpoint ID * @return the root path or {@code null} - * @deprecated since 2.0.6 in favor of {@link #getRootPath(EndpointId)} - */ - @Deprecated - public String getRootPath(String endpointId) { - return getRootPath(EndpointId.of(endpointId)); - } - - /** - * Return the root path for the endpoint with the given ID or {@code null} if the - * endpoint cannot be found. - * @param endpointId the endpoint ID - * @return the root path or {@code null} - * @since 2.0.6 */ public String getRootPath(EndpointId endpointId) { PathMappedEndpoint endpoint = getEndpoint(endpointId); @@ -114,19 +101,6 @@ public class PathMappedEndpoints implements Iterable { * endpoint cannot be found. * @param endpointId the endpoint ID * @return the full path or {@code null} - * @deprecated since 2.0.6 in favor of {@link #getPath(EndpointId)} - */ - @Deprecated - public String getPath(String endpointId) { - return getPath(EndpointId.of(endpointId)); - } - - /** - * Return the full path for the endpoint with the given ID or {@code null} if the - * endpoint cannot be found. - * @param endpointId the endpoint ID - * @return the full path or {@code null} - * @since 2.0.6 */ public String getPath(EndpointId endpointId) { return getPath(getEndpoint(endpointId)); @@ -153,19 +127,6 @@ public class PathMappedEndpoints implements Iterable { * endpoint cannot be found. * @param endpointId the endpoint ID * @return the path mapped endpoint or {@code null} - * @deprecated since 2.0.6 in favor of {@link #getEndpoint(EndpointId)} - */ - @Deprecated - public PathMappedEndpoint getEndpoint(String endpointId) { - return getEndpoint(EndpointId.of(endpointId)); - } - - /** - * Return the {@link PathMappedEndpoint} with the given ID or {@code null} if the - * endpoint cannot be found. - * @param endpointId the endpoint ID - * @return the path mapped endpoint or {@code null} - * @since 2.0.6 */ public PathMappedEndpoint getEndpoint(EndpointId endpointId) { return this.endpoints.get(endpointId); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMapper.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMapper.java index 12af95b1fd..e67027265c 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMapper.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMapper.java @@ -33,40 +33,15 @@ public interface PathMapper { * Resolve the root path for the endpoint with the specified {@code endpointId}. * @param endpointId the id of an endpoint * @return the path of the endpoint - * @since 2.0.6 */ - default String getRootPath(EndpointId endpointId) { - return getRootPath((endpointId != null) ? endpointId.toString() : null); - } - - /** - * Resolve the root path for the endpoint with the specified {@code endpointId}. - * @param endpointId the id of an endpoint - * @return the path of the endpoint - * @deprecated since 2.0.6 in favor of {@link #getRootPath(EndpointId)} - */ - @Deprecated - String getRootPath(String endpointId); + String getRootPath(EndpointId endpointId); /** * Returns an {@link PathMapper} that uses the endpoint ID as the path. * @return an {@link PathMapper} that uses the lowercase endpoint ID as the path */ static PathMapper useEndpointId() { - return new PathMapper() { - - @Override - @Deprecated - public String getRootPath(String endpointId) { - return getRootPath(EndpointId.of(endpointId)); - } - - @Override - public String getRootPath(EndpointId endpointId) { - return endpointId.toLowerCaseString(); - } - - }; + return (id) -> id.toLowerCaseString(); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscoverer.java index 8842b20ce4..ef638a44cb 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscoverer.java @@ -67,14 +67,6 @@ public class ControllerEndpointDiscoverer || AnnotatedElementUtils.isAnnotated(type, RestControllerEndpoint.class); } - @Override - @Deprecated - protected ExposableControllerEndpoint createEndpoint(Object endpointBean, String id, - boolean enabledByDefault, Collection operations) { - return createEndpoint(endpointBean, (id != null) ? EndpointId.of(id) : null, - enabledByDefault, operations); - } - @Override protected ExposableControllerEndpoint createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, Collection operations) { @@ -83,13 +75,6 @@ public class ControllerEndpointDiscoverer enabledByDefault); } - @Override - @Deprecated - protected Operation createOperation(String endpointId, - DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { - return createOperation(EndpointId.of(endpointId), operationMethod, invoker); - } - @Override protected Operation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscoverer.java index fa127b40c0..5b916655cc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscoverer.java @@ -66,14 +66,6 @@ public class ServletEndpointDiscoverer return AnnotatedElementUtils.isAnnotated(type, ServletEndpoint.class); } - @Override - @Deprecated - protected ExposableServletEndpoint createEndpoint(Object endpointBean, String id, - boolean enabledByDefault, Collection operations) { - return createEndpoint(endpointBean, EndpointId.of(id), enabledByDefault, - operations); - } - @Override protected ExposableServletEndpoint createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, Collection operations) { @@ -82,13 +74,6 @@ public class ServletEndpointDiscoverer enabledByDefault); } - @Override - @Deprecated - protected Operation createOperation(String endpointId, - DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { - return createOperation(EndpointId.of(endpointId), operationMethod, invoker); - } - @Override protected Operation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscoverer.java index e6feb3f98a..3db0697a60 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscoverer.java @@ -68,14 +68,6 @@ public class WebEndpointDiscoverer this.requestPredicateFactory = new RequestPredicateFactory(endpointMediaTypes); } - @Override - @Deprecated - protected ExposableWebEndpoint createEndpoint(Object endpointBean, String id, - boolean enabledByDefault, Collection operations) { - return createEndpoint(endpointBean, EndpointId.of(id), enabledByDefault, - operations); - } - @Override protected ExposableWebEndpoint createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, Collection operations) { @@ -84,13 +76,6 @@ public class WebEndpointDiscoverer enabledByDefault, operations); } - @Override - @Deprecated - protected WebOperation createOperation(String endpointId, - DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { - return createOperation(EndpointId.of(endpointId), operationMethod, invoker); - } - @Override protected WebOperation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactoryTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactoryTests.java index f8fc5d3e3e..be2d39c33e 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactoryTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactoryTests.java @@ -223,13 +223,6 @@ public class DiscoveredOperationsFactoryTests { return invoker; } - @Override - @Deprecated - public OperationInvoker apply(String endpointId, OperationType operationType, - OperationParameters parameters, OperationInvoker invoker) { - throw new IllegalStateException(); - } - public EndpointId getEndpointId() { return this.endpointId; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java index a26a0773ab..a465f180bc 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java @@ -263,8 +263,8 @@ public class EndpointDiscovererTests { public void getEndpointsShouldApplyFilters() { load(SpecializedEndpointsConfiguration.class, (context) -> { EndpointFilter filter = (endpoint) -> { - String id = endpoint.getId(); - return !id.equals("specialized"); + EndpointId id = endpoint.getEndpointId(); + return !id.equals(EndpointId.of("specialized")); }; SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer( context, Collections.singleton(filter)); @@ -519,12 +519,6 @@ public class EndpointDiscovererTests { super(applicationContext, parameterValueMapper, invokerAdvisors, filters); } - @Override - protected TestExposableEndpoint createEndpoint(Object endpointBean, String id, - boolean enabledByDefault, Collection operations) { - throw new IllegalStateException(); - } - @Override protected TestExposableEndpoint createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, Collection operations) { @@ -533,7 +527,7 @@ public class EndpointDiscovererTests { } @Override - protected TestOperation createOperation(String endpointId, + protected TestOperation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { return new TestOperation(operationMethod, invoker); } @@ -559,13 +553,6 @@ public class EndpointDiscovererTests { Collections.emptyList(), filters); } - @Override - protected SpecializedExposableEndpoint createEndpoint(Object endpointBean, - String id, boolean enabledByDefault, - Collection operations) { - throw new IllegalStateException(); - } - @Override protected SpecializedExposableEndpoint createEndpoint(Object endpointBean, EndpointId id, boolean enabledByDefault, @@ -575,7 +562,7 @@ public class EndpointDiscovererTests { } @Override - protected SpecializedOperation createOperation(String endpointId, + protected SpecializedOperation createOperation(EndpointId endpointId, DiscoveredOperationMethod operationMethod, OperationInvoker invoker) { return new SpecializedOperation(operationMethod, invoker); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestExposableJmxEndpoint.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestExposableJmxEndpoint.java index 1f20bcdab6..e063a19ca7 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestExposableJmxEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestExposableJmxEndpoint.java @@ -19,6 +19,8 @@ package org.springframework.boot.actuate.endpoint.jmx; import java.util.Arrays; import java.util.Collection; +import org.springframework.boot.actuate.endpoint.EndpointId; + /** * Test {@link ExposableJmxEndpoint} implementation. * @@ -37,8 +39,8 @@ public class TestExposableJmxEndpoint implements ExposableJmxEndpoint { } @Override - public String getId() { - return "test"; + public EndpointId getEndpointId() { + return EndpointId.of("test"); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java index bf0a91ca14..cdff1542c3 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/WebEndpointDiscovererTests.java @@ -182,18 +182,19 @@ public class WebEndpointDiscovererTests { @Test public void getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue() { - load((id) -> 500L, (id) -> id, TestEndpointConfiguration.class, (discoverer) -> { - Map endpoints = mapEndpoints( - discoverer.getEndpoints()); - assertThat(endpoints).containsOnlyKeys(EndpointId.of("test")); - ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test")); - assertThat(endpoint.getOperations()).hasSize(1); - WebOperation operation = endpoint.getOperations().iterator().next(); - Object invoker = ReflectionTestUtils.getField(operation, "invoker"); - assertThat(invoker).isInstanceOf(CachingOperationInvoker.class); - assertThat(((CachingOperationInvoker) invoker).getTimeToLive()) - .isEqualTo(500); - }); + load((id) -> 500L, (id) -> id.toString(), TestEndpointConfiguration.class, + (discoverer) -> { + Map endpoints = mapEndpoints( + discoverer.getEndpoints()); + assertThat(endpoints).containsOnlyKeys(EndpointId.of("test")); + ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test")); + assertThat(endpoint.getOperations()).hasSize(1); + WebOperation operation = endpoint.getOperations().iterator().next(); + Object invoker = ReflectionTestUtils.getField(operation, "invoker"); + assertThat(invoker).isInstanceOf(CachingOperationInvoker.class); + assertThat(((CachingOperationInvoker) invoker).getTimeToLive()) + .isEqualTo(500); + }); } @Test @@ -245,7 +246,7 @@ public class WebEndpointDiscovererTests { } private void load(Class configuration, Consumer consumer) { - this.load((id) -> null, (id) -> id, configuration, consumer); + this.load((id) -> null, (id) -> id.toString(), configuration, consumer); } private void load(Function timeToLive,