Philippe Marschall opened SPR-15749 and commented
Most places in spring-tx treat RuntimeException
and Error
equally rolling back in both cases as both of them are unchecked. This can be seen in TransactionAspectSupport. completeTransactionAfterThrowing and DefaultTransactionAttribute. rollbackOn
The execution path for CallbackPreferringPlatformTransactionManager
seems to be different
https://github.com/spring-projects/spring-framework/blob/master/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java#L319
where an Error
is not thrown but instead wrapped in a ThrowableHolderException
. However looking at the code in UOWActionAdapter.run (used by the only present implementation of CallbackPreferringPlatformTransactionManager) any kind of Throwable
seems to cause a rollback. It seems to me as if RuntimeException
and Error
should be treated equally in the CallbackPreferringPlatformTransactionManager
path in TransactionAspectSupport.java
Affects: 4.3.9
Comment From: jhoeller
This is trying to prevent the direct propagation of Error
to the (WebSphere) server that calls us back there (since the server might allergically react to that), rather unwrapping the holder exception back to an Error
once we are in control of the call stack again.
Also, the WebSphere implementation is not available in Spring Framework 6.x anymore, so the entire mechanism is only really there for custom external integration purposes now.