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

javax.xml.datatype.Duration.compare throws NPE if second is undefined

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description



        Name: erR10175 Date: 06/11/2004



          The default implementation of the following method of the class javax.xml.datatype.Duration

        public abstract int compare(Duration duration)

        throws NullPointerException if second field of the duration is undefined.

        According to the javadoc of the method NPE may be thrown only if the
        duration parameter is null.

        The bug is found in jaxp-1.3-b18 and is not reproducible with neither
        jck15-b55 nor jaxp-1.3-b17.

        The bug affects the following new JAXP TCK 1.3 tests:

          api/javax_xml/datatype/Duration/index.html#Duration[Compare001]
          api/javax_xml/datatype/Duration/index.html#Duration[Equals001]
          api/javax_xml/datatype/Duration/index.html#Duration[IsLongerThan001]
          api/javax_xml/datatype/Duration/index.html#Duration[IsShorterThan001]
          api/javax_xml/datatype/Duration/index.html#Multiply[Multiply001]
          api/javax_xml/datatype/Duration/index.html#Multiply[Multiply002]
          api/javax_xml/datatype/Duration/index.html#Negate[Negate001]
          api/javax_xml/datatype/Duration/index.html#NormalizeWith[NormalizeWith001]
          api/javax_xml/datatype/Duration/index.html#Subtract[Subtract001]

        To reproduce the bug compile and run the following code as shown in the log below.
        Set the java.endorsed.dirs property to jaxp-1.3-beta-b18 directory.
        --------------------------- test.java
        import javax.xml.datatype.Duration;
        import javax.xml.datatype.DatatypeFactory;

        class test {

            public static void main(String [] args) throws Exception {
                DatatypeFactory df = DatatypeFactory.newInstance();
                Duration duration1 = df.newDuration("P1Y");
                Duration duration2 = df.newDuration("P1YT1S");
                duration1.compare(duration2);
                System.out.print("Step 1: ");
                duration2 = df.newDuration("P1Y");
                System.out.println("Passed.");
                System.out.print("Step 2: ");
                duration1.compare(duration2);
                System.out.println("Passed.");
            }
        }
        -------------------------------------

        --------------------------------- log
        $javac test.java && java -cp . -Djava.endorsed.dirs=jaxp-1.3-beta-b18-09_jun_2004 -showversion test
        java version "1.5.0-beta3"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b55)
        Java HotSpot(TM) Client VM (build 1.5.0-beta3-b55, mixed mode)

        Step 1: Passed.
        Step 2: Exception in thread "main" java.lang.NullPointerException
                at org.apache.xerces.jaxp.datatype.DurationImpl.compare(Unknown Source)
                at test.main(test.java:15)
        -------------------------------------

        ======================================================================

        Name: erR10175 Date: 06/20/2004


        The following JCK 1.5 tests fail with jdk15-b56 due to this bug:

        api/javax_xml/datatype/DatatypeFactory/index.html#Duration[NewDuration003]
        api/javax_xml/datatype/DatatypeFactory/index.html#Duration[NewDuration007]
        api/javax_xml/datatype/DatatypeFactory/index.html#Duration[NewDuration008]
        api/javax_xml/datatype/Duration/index.html#Add[Add001]
        api/javax_xml/datatype/Duration/index.html#Duration[Compare001]
        api/javax_xml/datatype/Duration/index.html#Duration[Equals001]
        api/javax_xml/datatype/Duration/index.html#Duration[IsLongerThan001]
        api/javax_xml/datatype/Duration/index.html#Duration[IsShorterThan001]
        api/javax_xml/datatype/Duration/index.html#Multiply[Multiply001]
        api/javax_xml/datatype/Duration/index.html#Multiply[Multiply002]
        api/javax_xml/datatype/Duration/index.html#Negate[Negate001]
        api/javax_xml/datatype/Duration/index.html#NormalizeWith[NormalizeWith001]
        api/javax_xml/datatype/Duration/index.html#Subtract[Subtract001]


        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rmandavasunw Ramesh Mandava (Inactive)
                  Reporter:
                  reysunw Rey Rey (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: