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

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

XMLWordPrintable

    • b58
    • generic
    • generic

      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.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: