- changed status to open
Class com.nimbusds.oauth2.sdk.id.Issuer overrides equals() but not hashCode()
The current implementation of the com.nimbusds.oauth2.sdk.id.Issuer
class has an override of the equals()
method, but doesn't have a corresponding override of hashCode()
.
Semantically speaking, this is currently not causing any problems, since the equals()
implementation compares the return value of toString()
, which happens to be the same as the one of getValue()
. At the same time, the parent class com.nimbusds.oauth2.sdk.id.Identifier
implements hashCode()
by delegating to the result of the getValue()
method call.
However, this is not very readable and maintainable, and is easy to break. To reduce the likelihood of breaking the equals-hashCode contract both overrides should be present in the Issuer
class.
Comments (2)
-
-
- changed status to wontfix
Hi,
The Issuer class is declared final, so the used hashCode from the parent Identifier class cannot be overridden. Unless you put Issuer instances in a bag that contains other Issuer-based classes the current hashing method is adequate.
If you have a concrete case where the current approach won’t work, please reopen the ticket with a description of the case and a few code samples / tests if possible.
- Log in to comment