You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Benjamin Weidig (Jira)" <ji...@apache.org> on 2021/01/06 12:28:00 UTC

[jira] [Created] (TAP5-2658) Tuple should implement hashCode based on its values

Benjamin Weidig created TAP5-2658:
-------------------------------------

             Summary: Tuple should implement hashCode based on its values
                 Key: TAP5-2658
                 URL: https://issues.apache.org/jira/browse/TAP5-2658
             Project: Tapestry 5
          Issue Type: Bug
          Components: tapestry-func
    Affects Versions: 5.6.2, 5.7.0
            Reporter: Benjamin Weidig


h2. Summary

The class `org.apache.tapestry5.func.Tuple<A, B>` overrides `boolean equals(Object)` to check equality of its values.
 But it doesn't provide an appropriate `int hashCode()` implementation, thereby violating a base contract of Java objects, leading to undefined behavior depending on someone using the hash code value.
h2. Risks and Assumptions

Minimal risk is assumed.
 Usage in HashMaps, or other hash code related structures/methods might behave differently.
 But due to the previously broken contract, it should affect code using it "wrong".
h2. Alternatives

Deprecating Tuple, and providing a new implementation.
h2. Details of Proposed Changes

Add `hashCode()` based on `java.util.Objects.hash(Object...)`.
Add tests for `hashCode()`.



Code is already implemented and ready to be committed and pushed, if change is accepted.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)