Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
3cb2246e
Commit
3cb2246e
authored
Apr 16, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
f139dc36
0bc7bef5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
EndpointMBean.java
...ingframework/boot/actuate/endpoint/jmx/EndpointMBean.java
+6
-11
EndpointMBeanTests.java
...amework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java
+19
-0
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java
View file @
3cb2246e
...
@@ -93,27 +93,22 @@ public class EndpointMBean implements DynamicMBean {
...
@@ -93,27 +93,22 @@ public class EndpointMBean implements DynamicMBean {
return
invoke
(
operation
,
params
);
return
invoke
(
operation
,
params
);
}
}
private
Object
invoke
(
JmxOperation
operation
,
Object
[]
params
)
throws
MBeanException
{
private
Object
invoke
(
JmxOperation
operation
,
Object
[]
params
)
throws
MBeanException
,
ReflectionException
{
try
{
try
{
String
[]
parameterNames
=
operation
.
getParameters
().
stream
()
String
[]
parameterNames
=
operation
.
getParameters
().
stream
()
.
map
(
JmxOperationParameter:
:
getName
).
toArray
(
String
[]::
new
);
.
map
(
JmxOperationParameter:
:
getName
).
toArray
(
String
[]::
new
);
Map
<
String
,
Object
>
arguments
=
getArguments
(
parameterNames
,
params
);
Map
<
String
,
Object
>
arguments
=
getArguments
(
parameterNames
,
params
);
Object
result
=
invokeOperation
(
operation
,
arguments
);
Object
result
=
operation
.
invoke
(
new
InvocationContext
(
SecurityContext
.
NONE
,
arguments
));
if
(
REACTOR_PRESENT
)
{
if
(
REACTOR_PRESENT
)
{
result
=
ReactiveHandler
.
handle
(
result
);
result
=
ReactiveHandler
.
handle
(
result
);
}
}
return
this
.
responseMapper
.
mapResponse
(
result
);
return
this
.
responseMapper
.
mapResponse
(
result
);
}
}
catch
(
InvalidEndpointRequestException
ex
)
{
catch
(
InvalidEndpointRequestException
ex
)
{
throw
new
IllegalArgumentException
(
ex
.
getMessage
(),
ex
);
throw
new
ReflectionException
(
new
IllegalArgumentException
(
}
ex
.
getMessage
()),
ex
.
getMessage
());
}
private
Object
invokeOperation
(
JmxOperation
operation
,
Map
<
String
,
Object
>
arguments
)
throws
MBeanException
{
try
{
return
operation
.
invoke
(
new
InvocationContext
(
SecurityContext
.
NONE
,
arguments
));
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
throw
new
MBeanException
(
translateIfNecessary
(
ex
),
ex
.
getMessage
());
throw
new
MBeanException
(
translateIfNecessary
(
ex
),
ex
.
getMessage
());
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java
View file @
3cb2246e
...
@@ -30,6 +30,8 @@ import org.junit.rules.ExpectedException;
...
@@ -30,6 +30,8 @@ import org.junit.rules.ExpectedException;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
org.springframework.beans.FatalBeanException
;
import
org.springframework.beans.FatalBeanException
;
import
org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException
;
import
org.springframework.boot.actuate.endpoint.InvocationContext
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
CoreMatchers
.
instanceOf
;
import
static
org
.
hamcrest
.
CoreMatchers
.
instanceOf
;
...
@@ -124,6 +126,23 @@ public class EndpointMBeanTests {
...
@@ -124,6 +126,23 @@ public class EndpointMBeanTests {
bean
.
invoke
(
"missingOperation"
,
NO_PARAMS
,
NO_SIGNATURE
);
bean
.
invoke
(
"missingOperation"
,
NO_PARAMS
,
NO_SIGNATURE
);
}
}
@Test
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
);
this
.
thrown
.
expect
(
ReflectionException
.
class
);
this
.
thrown
.
expectCause
(
instanceOf
(
IllegalArgumentException
.
class
));
this
.
thrown
.
expectMessage
(
"test failure"
);
bean
.
invoke
(
"testOperation"
,
NO_PARAMS
,
NO_SIGNATURE
);
}
@Test
@Test
public
void
invokeWhenMonoResultShouldBlockOnMono
()
public
void
invokeWhenMonoResultShouldBlockOnMono
()
throws
MBeanException
,
ReflectionException
{
throws
MBeanException
,
ReflectionException
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment