diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxOperation.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxOperation.java index aabf44c992..e9b53774f6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxOperation.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JmxOperation.java @@ -95,7 +95,9 @@ public class JmxOperation extends Operation { @Override public String toString() { - return new ToStringCreator(this).append("operationName", this.operationName) + return new ToStringCreator(this).append("type", getType()) + .append("invoker", getInvoker()).append("blocking", isBlocking()) + .append("operationName", this.operationName) .append("outputType", this.outputType) .append("description", this.description).toString(); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/reflect/ReflectiveOperationInvoker.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/reflect/ReflectiveOperationInvoker.java index d3294d767b..ae4037c4eb 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/reflect/ReflectiveOperationInvoker.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/reflect/ReflectiveOperationInvoker.java @@ -22,6 +22,7 @@ import java.util.Set; import java.util.stream.Collectors; import org.springframework.boot.actuate.endpoint.OperationInvoker; +import org.springframework.core.style.ToStringCreator; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; @@ -103,4 +104,10 @@ public class ReflectiveOperationInvoker implements OperationInvoker { return this.parameterMapper.mapParameter(resolved, parameter.getType()); } + @Override + public String toString() { + return new ToStringCreator(this).append("target", this.target) + .append("method", this.methodInfo.getMethod().toString()).toString(); + } + } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperation.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperation.java index a5257e5b26..cb9b66ffa4 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperation.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperation.java @@ -19,6 +19,7 @@ package org.springframework.boot.actuate.endpoint.web; import org.springframework.boot.actuate.endpoint.Operation; import org.springframework.boot.actuate.endpoint.OperationInvoker; import org.springframework.boot.actuate.endpoint.OperationType; +import org.springframework.core.style.ToStringCreator; /** * An operation on a web endpoint. @@ -65,4 +66,12 @@ public class WebOperation extends Operation { return this.id; } + @Override + public String toString() { + return new ToStringCreator(this).append("type", getType()) + .append("invoker", getInvoker()).append("blocking", isBlocking()) + .append("requestPredicate", getRequestPredicate()).append("id", getId()) + .toString(); + } + } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxAnnotationEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxAnnotationEndpointDiscovererTests.java index 6e2be1de7f..954b5ee0a0 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxAnnotationEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/annotation/JmxAnnotationEndpointDiscovererTests.java @@ -47,6 +47,7 @@ import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.jmx.export.annotation.ManagedOperation; import org.springframework.jmx.export.annotation.ManagedOperationParameter; import org.springframework.jmx.export.annotation.ManagedOperationParameters; +import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -216,6 +217,11 @@ public class JmxAnnotationEndpointDiscovererTests { this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Found multiple JMX operations with the same name"); this.thrown.expectMessage("getAll"); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingOperationsEndpoint.class, "getAll").toString()); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingOperationsEndpoint.class, "getAll", String.class) + .toString()); discoverer.discoverEndpoints(); }); } @@ -226,6 +232,13 @@ public class JmxAnnotationEndpointDiscovererTests { this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Found multiple JMX operations with the same name"); this.thrown.expectMessage("getAll"); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingOperationsJmxEndpointExtension.class, "getAll") + .toString()); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingOperationsJmxEndpointExtension.class, "getAll", + String.class) + .toString()); discoverer.discoverEndpoints(); }); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/WebAnnotationEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/WebAnnotationEndpointDiscovererTests.java index def3cb6fdd..704226c63d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/WebAnnotationEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/WebAnnotationEndpointDiscovererTests.java @@ -54,6 +54,7 @@ import org.springframework.context.annotation.Import; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; +import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -162,6 +163,10 @@ public class WebAnnotationEndpointDiscovererTests { this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage( "Found multiple web operations with matching request predicates:"); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingOperationsEndpoint.class, "getAll").toString()); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingOperationsEndpoint.class, "getAgain").toString()); discoverer.discoverEndpoints(); }); } @@ -183,6 +188,14 @@ public class WebAnnotationEndpointDiscovererTests { this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage( "Found multiple web operations with matching request predicates:"); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingSelectorsWebEndpointExtension.class, "readOne", + String.class, String.class) + .toString()); + this.thrown.expectMessage(ReflectionUtils + .findMethod(ClashingSelectorsWebEndpointExtension.class, "readTwo", + String.class, String.class) + .toString()); discoverer.discoverEndpoints(); }); }