OpenJPA
  1. OpenJPA
  2. OPENJPA-1120

idEquals() broken in BigDecimalId and BigIntegerId

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.3, 1.1.0, 1.2.1, 1.3.0, 2.0.0
    • Fix Version/s: 1.3.0, 2.0.0-M3
    • Component/s: jpa
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      in openjpa/util/BigDecimalId and open/util/BigIntegerId the idEquals-methods compare their own keys to the other object, not to others.key.
      That would always result in false - which is false sometimes

      1. BrokenEqualsId.patch
        1 kB
        dieter von holten

        Activity

        Hide
        Albert Lee added a comment -

        Need to check if "other" is a BigDecimalId or a subclass of BigDecimalId, otherwise a ClassCastException will occur in the return statement.

        if(key == null || ! BigDecimalId.class.isAssignableFrom(other.getClass()))
        return false;

        return key.equals(((BigDecimalId)other).key);

        Albert Lee.

        Show
        Albert Lee added a comment - Need to check if "other" is a BigDecimalId or a subclass of BigDecimalId, otherwise a ClassCastException will occur in the return statement. if(key == null || ! BigDecimalId.class.isAssignableFrom(other.getClass())) return false; return key.equals(((BigDecimalId)other).key); Albert Lee.
        Hide
        Donald Woods added a comment -

        Applied to trunk as Rev799132 and 1.3.x as Rev799142.
        Mike, can you consider applying the changes to 1.2.x and maybe 1.0.x?

        Show
        Donald Woods added a comment - Applied to trunk as Rev799132 and 1.3.x as Rev799142. Mike, can you consider applying the changes to 1.2.x and maybe 1.0.x?
        Hide
        Michael Dick added a comment -

        I'd like to see a testcase before deciding to include this fix in 1.2.x. It seems fairly straightforward but it'd be good to have one to prevent future regressions in this area.

        Show
        Michael Dick added a comment - I'd like to see a testcase before deciding to include this fix in 1.2.x. It seems fairly straightforward but it'd be good to have one to prevent future regressions in this area.

          People

          • Assignee:
            Donald Woods
            Reporter:
            dieter von holten
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development