Details
-
Type:
Bug
-
Status: Open
-
Priority:
Critical
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: 2.0 M1
-
Component/s: None
-
Labels:None
Description
in SimpleExecutionStrategy:
try { Object result = invoke(parseResult); processor.afterReturningInvocation(parseResult, result); return result; } catch (Throwable th) { processor.afterThrowingInvocation(parseResult, th); return handleThrowable(th); }
Which can be expanded to the following after substituting invoke function with it's contents:
try { Object result; try { result = ReflectionUtils.invokeMethod(parseResult.getMethod(), parseResult.getInstance(), parseResult.getArguments()); } catch (Throwable th) { logger.severe("Command failed " + th); result = handleThrowable(th); } processor.afterReturningInvocation(parseResult, result); return result; } catch (Throwable th) { processor.afterThrowingInvocation(parseResult, th); return handleThrowable(th); }
Looking at `ReflectionUtils.invokeMethod`, we see that it doesn't throw anything, it lets some RuntimeExceptions through, converts others to subclasses of RuntimeException, and wraps the rest in UndeclaredThrowableException.
Now, after invoking a method with `ReflectionUtils.invokeMethod`, the checked exceptions come wrapped in `UndeclaredThrowableException`. Which is then caught as shown in the first snippet and log comes:
Command failed java.lang.reflect.UndeclaredThrowableException
Another thing, the exception that gets passed to `afterThrowingInvocation` is the UndeclaredThrowableException, which also seems fishy to me. It should get the original exception without any wrapping.