This commit is contained in:
Phillip Webb
2018-05-04 19:04:28 -07:00
parent f9750248ef
commit 975e986fef
6 changed files with 83 additions and 90 deletions

View File

@@ -99,8 +99,9 @@ public class EndpointMBean implements DynamicMBean {
String[] parameterNames = operation.getParameters().stream()
.map(JmxOperationParameter::getName).toArray(String[]::new);
Map<String, Object> arguments = getArguments(parameterNames, params);
Object result = operation
.invoke(new InvocationContext(SecurityContext.NONE, arguments));
InvocationContext context = new InvocationContext(SecurityContext.NONE,
arguments);
Object result = operation.invoke(context);
if (REACTOR_PRESENT) {
result = ReactiveHandler.handle(result);
}
@@ -119,9 +120,7 @@ public class EndpointMBean implements DynamicMBean {
if (exception.getClass().getName().startsWith("java.")) {
return exception;
}
else {
return new IllegalStateException(exception.getMessage());
}
return new IllegalStateException(exception.getMessage());
}
private Map<String, Object> getArguments(String[] parameterNames, Object[] params) {

View File

@@ -130,10 +130,12 @@ public class EndpointMBeanTests {
public void invokeWhenOperationIsInvalidShouldThrowException()
throws MBeanException, ReflectionException {
TestJmxOperation operation = new TestJmxOperation() {
@Override
public Object invoke(InvocationContext context) {
throw new InvalidEndpointRequestException("test failure", "test");
}
};
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(operation);
EndpointMBean bean = new EndpointMBean(this.responseMapper, endpoint);