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

Add proper equals (and hashCode) methods to OAuth2AuthorizationRequest #16394

Open
GrmpfNarf opened this issue Jan 10, 2025 · 0 comments
Open
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement

Comments

@GrmpfNarf
Copy link

Expected Behavior

The class org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest should have proper equals and hashCode methods.

Current Behavior

The class does not have an overriden equals or hashCode method which makes proper comparison of two instances difficult.

Context
I save this class into a database and read it back with JPA and Hibernate. This is done in some customization of the project:
spring-authorization-server.
However, Hibernate has the funcationality to detect changes in an entity and send an update to this entity to the database. For this function the equals method of custom types is called. Hibernate holds a copy of the entity in cache and compare this one with the one delivered to the application.
Because of the missing proper equals method of the given class an update is triggered everytime the entity is read from the database.
I understand that this may be a special case in comibnation with Hibernate but the lack of the method ensures that comparisons are maybe not accurate enough.

Workaround
To prevent this issue i wrap a custom datatype around the OAuth2AuthorizationRequest which adds the missing equals functionality.

@GrmpfNarf GrmpfNarf added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant