https://issues.apache.org/bugzilla/show_bug.cgi?id=56446
Bug ID: 56446
Summary: Handling InvocationTargetException for
PojoMessageHandlerWholeBase and
PojoMessageHandlerPartialBase.onMessage()
Product: Tomcat 8
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: WebSocket
Assignee: [email protected]
Reporter: [email protected]
Both two methods handle InvocationTargetException from Endpoint @OnMessage
method like this:
try {
result = method.invoke(pojo, parameters);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
I'd like to suggest to use
org.apache.tomcat.util.ExceptionUtils#unwrapInvocationTargetException() and
RuntimeException
, which is like below:
try {
result = method.invoke(pojo, parameters);
} catch (IllegalAccessException | InvocationTargetException e) {
Throwable throwable =
ExceptionUtils.unwrapInvocationTargetException(e);
if (throwable instanceof RuntimeException) {
throw (RuntimeException) throwable;
} else {
throw new RuntimeException(throwable);
}
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]