Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2658

Tuple should implement hashCode based on its values

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.6.2, 5.7.0
    • Component/s: tapestry-func
    • Labels:
      None

      Description

      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.

      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".

      Alternatives

      Deprecating Tuple, and providing a new implementation.

      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.

        Attachments

          Activity

            People

            • Assignee:
              ben-ng Ben Weidig
              Reporter:
              ben-ng Ben Weidig
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: