Skip to content

Clarify rollback-on consistency between DefaultTransactionAttribute and TransactionTemplate [SPR-14994] #19560

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 953bc18, 0296c7c, 2de488e

Backported to: 4.2.9

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions