Skip to content
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

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

Closed
spring-projects-issues opened this issue Mar 9, 2018 · 5 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

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

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

Arne Vandamme commented

PR added with proposed change: #1736

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

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

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

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

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

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

@spring-projects-issues spring-projects-issues commented Mar 9, 2018

Arne Vandamme commented

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.