Description
Gary Russell opened SPR-14994 and commented
The DefaultTransactionAttribute.rollbackOn()
javadoc says it is "consistent with the TransactionTemplate
's default behavior"...
/**
* The default behavior is as with EJB: rollback on unchecked exception.
* Additionally attempt to rollback on Error.
* <p>This is consistent with TransactionTemplate's default behavior.
*/
@Override
public boolean rollbackOn(Throwable ex) {
return (ex instanceof RuntimeException || ex instanceof Error);
}
Since #11027, this is no longer strictly correct, in that a rollback will occur for any exception there.
Of course, as seen in that JIRA attachment, actually throwing a checked exception is a bit convoluted (reflection on a ctor that throws a checked exception), so perhaps this is ok.
However when looking at the code it appears incorrect and I had to dig back into the commit history to understand what's going on; perhaps adding a comment to the template code where we catch Exception
(now Throwable
since #18901) would help.
Or, Juergen Hoeller, feel free to just close this if you don't think any changes are warranted.
Affects: 4.2.8, 4.3.4
Issue Links:
- TransactionTemplate leaks transactions when TransactionCallback propagates undeclared checked exception [SPR-6361] #11027 TransactionTemplate leaks transactions when TransactionCallback propagates undeclared checked exception
- After-completion callback not triggered for custom Throwable subclass [SPR-14329] #18901 After-completion callback not triggered for custom Throwable subclass
Referenced from: commits 953bc18, 0296c7c, 2de488e
Backported to: 4.2.9