XMLGregorianCalendar.equals() doesn't throw NPE if argument is null

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 1.3.0
    • Affects Version/s: 5.0
    • Component/s: xml
    • 1.6
    • generic
    • generic

      JDK5.0-b64
      According to the spec for XMLGregorianCalendar.equals() but contrary to the spec for Object.equals() the mthod should throw NPE if an argument is null.

      However if we invoke equals with null argument then NPE is not thrown. You reproduce it by following code:

      import javax.xml.datatype.DatatypeConfigurationException;
      import javax.xml.datatype.DatatypeFactory;
      import javax.xml.datatype.XMLGregorianCalendar;


      class test {

          public static void main(String [] args) throws Exception {
              DatatypeFactory factory = null;
              try {
                  factory = DatatypeFactory.newInstance();
              } catch (DatatypeConfigurationException dce) {
                  dce.printStackTrace();
              }

              XMLGregorianCalendar calendar =
                      factory.newXMLGregorianCalendar();
              calendar.equals(null);
              System.out.println("OK");
          }
      }

      It should print stack trace but prints OK.

      ###@###.### 2005-03-11 14:03:16 GMT

      integrated in tag JWSDP-1_6-b08
      ###@###.### 2005-05-02 23:04:18 GMT

            Assignee:
            J. Duke
            Reporter:
            Yury Danilevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: