Commons Dbcp
  1. Commons Dbcp
  2. DBCP-317

Findbugs: Class doesn't override equals in superclass

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.0
    • Labels:
      None

      Description

      Findbugs: Class doesn't override equals in superclass - 8 instances

      "This class extends a class that defines an equals method and adds fields, but doesn't define an equals method itself. Thus, equality on instances of this class will ignore the identity of the subclass and the added fields. Be sure this is what is intended, and that you don't need to override the equals method. Even if you don't need to override the equals method, consider overriding it anyway to document the fact that the equals method for the subclass just return the result of invoking super.equals(o). "

      Classes (superclass) are:

      cpdsadapter.ConnectionImpl doesn't override DelegatingConnection.equals
      datasources.LRUMap doesn't override SequencedHashMap.equals
      managed.ManagedConnection doesn't override DelegatingConnection.equals
      managed.PoolableManagedConnection doesn't override DelegatingConnection.equals
      PoolableCallableStatement doesn't override DelegatingCallableStatement.equals
      PoolableConnection doesn't override DelegatingConnection.equals
      PoolablePreparedStatement doesn't override DelegatingPreparedStatement.equals
      PoolingConnection doesn't override DelegatingConnection.equals

        Issue Links

          Activity

          Hide
          Phil Steitz added a comment -

          I don't want to make any changes to the collections class (LRUMap), which is OK.

          The others are OK - working as designed - as the equals equivalence relation is defined by equality of underlying jdbc objects. I am OK with vacuos override to document if that would make findbugs happier and the code easier to understand, though I am not sure it would make the code easier to understand.

          Show
          Phil Steitz added a comment - I don't want to make any changes to the collections class (LRUMap), which is OK. The others are OK - working as designed - as the equals equivalence relation is defined by equality of underlying jdbc objects. I am OK with vacuos override to document if that would make findbugs happier and the code easier to understand, though I am not sure it would make the code easier to understand.
          Hide
          Sebb added a comment -

          I've been looking into this further.

          DelegatingPreparedStatement extends DelegatingStatement and overrides equals() - but defines no extra fields
          DelegatingCallableStatement extends DelegatingPreparedStatement and overrides equals() - but defines no extra fields
          Yet
          PoolableCallableStatement extends DelegatingCallableStatement and has extra fields, but does not override equals()

          This is quite confusing - why do the Delagating...Statement classes override equals when they don't have any extra state?
          Indeed Findbugs warns that these equals methods may not be symmetric.

          Show
          Sebb added a comment - I've been looking into this further. DelegatingPreparedStatement extends DelegatingStatement and overrides equals() - but defines no extra fields DelegatingCallableStatement extends DelegatingPreparedStatement and overrides equals() - but defines no extra fields Yet PoolableCallableStatement extends DelegatingCallableStatement and has extra fields, but does not override equals() This is quite confusing - why do the Delagating...Statement classes override equals when they don't have any extra state? Indeed Findbugs warns that these equals methods may not be symmetric.
          Hide
          Mark Thomas added a comment -

          I've fixed (removed) the unnecessary equals() methods in DelegatingPreparedStatement and DelegatingCallableStatement

          The issues in the original description are still to be resolved.

          Show
          Mark Thomas added a comment - I've fixed (removed) the unnecessary equals() methods in DelegatingPreparedStatement and DelegatingCallableStatement The issues in the original description are still to be resolved.
          Hide
          Mark Thomas added a comment -

          This issue has the same root cause as DBCP-358. Fixing that issue has also resolved these FindBugs warnings.

          Show
          Mark Thomas added a comment - This issue has the same root cause as DBCP-358 . Fixing that issue has also resolved these FindBugs warnings.

            People

            • Assignee:
              Unassigned
              Reporter:
              Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development