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

Tuple should implement hashCode based on its values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 5.6.2, 5.7.0
    • tapestry-func
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: