Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6325160

javax.xml.datatype.Duration.equals() and ...XMLGregorianCalendar.equals() handle null incorrectly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: jaxp_1.4
    • Fix Version/s: 6
    • Component/s: xml
    • Subcomponent:
    • Resolved In Build:
      b58
    • CPU:
      generic
    • OS:
      generic

      Description

      The equals() method for both Duration and XMLGregorianCalendar specify
      that a NullPointerException is thrown if the parameter passed to the
      method is null. This seems to violate the general contract of
      Object.equals() which says: "For any non-null reference value x,
      x.equals(null) should return false". A generic method such as:

      public boolean isEqual(Object a, Object b) {
         return (a == b || (a != null && a.equals(b)));
      }

      should work for all Objects but would fail unexpectedly with a
      NullPointerException if it's passed instances of Duration or
      XMLGregorianCalendar along with null as the second parameter.
      The API JavaDocs have been updated.

        Attachments

          Activity

            People

            Assignee:
            duke J. Duke (Inactive)
            Reporter:
            nwalshsunw Norman Walsh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: