SpringSource/spring-integration — pull request #713 by garyrussell (2013-01-23 21:10:52+00:00)
Title: INT-2894 Do Not Leak ThrowableHolderException

The AbstractRequestHandlerAdvice uses an internal wrapper for
Throwable, in a similar fashion to the TransactionInterceptor.

Exceptions are unwrapped properly when exiting the invoke method so
callers are unaware of the wrapping.

The technique is used to avoid user errors (for example catching OOM
Errors and not propagating). User code (subclasses) only catch
Exceptions.

However, in the case of the ExpressionEvaluatingRequestHandlerAdvice,
the exception is included in any ErrorMessage sent to a failureChannel.

User code should not have to navigate these internal exceptions within
the cause tree.

Add a method to the abstract class unwrapExceptionIfNecessary, which
will unwrap the root cause exception if possible.

Add a method to the abstract class unwrapThrowableIfNecessary, which
will unwrap the root cause Throwable if possible.

Update tests to reduce the cause() traversals to refelect the
ThrowableHolderExceptions are no longer in the tree.

Add a test to verify a Throwable (such as an OOM) is properly
propagated.

Add a test to verify that when the root cause is a Throwable (and not
an Exception), the ErrorMessage sent to the failureChannel does not include
the ThrowableHolderException.