Skip to content

TransactionTemplate inherits equals()/hashCode() from DefaultTransactionDefinition [SPR-16572] #21114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Mar 9, 2018 · 5 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Arne Vandamme opened SPR-16572 and commented

Two TransactionTemplate instances are considered equal purely based on their DefaultTransactionDefinition properties, without taking the actual configured PlatformTransactionManager into account.

Cause: the TransactionTemplate class inherits equals() and hashCode() from DefaultTransactionDefinition. I would assume the actual PlatformTransactionManager should also be taken into account.


Affects: 4.3.14, 5.0.4

Referenced from: pull request #1736, and commits b1295d0, df80614

Backported to: 4.3.15

@spring-projects-issues
Copy link
Collaborator Author

Arne Vandamme commented

PR added with proposed change: #1736

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

We generally don't expect TransactionTemplate instances to get compared for equality, but point taken, since it inherits transaction definition equality semantics it should enforce the same transaction manager when compared to another TransactionTemplate instance.

@spring-projects-issues
Copy link
Collaborator Author

Arne Vandamme commented

Actually it is indeed not so much about deliberately comparing them for equality. But it has the nasty side effect you can't build for example a HashSet of the different TransactionTemplate beans. You do not get the result you would expect. That's also how I found out about this.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Alright, fixed in master for 5.0.5 now; I'll backport this to 4.3.15 ASAP.

@spring-projects-issues
Copy link
Collaborator Author

Arne Vandamme commented

Great, thanks! (as well for the implementation feedback)

@spring-projects-issues spring-projects-issues added type: bug A general bug in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants