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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 1.3.0
    • Component/s: xml
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.6
    • CPU:
      generic
    • OS:
      generic

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: