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

DatatypeFactory.newDurationDayTime throws NPE if second is null

XMLWordPrintable

    • 1.3
    • generic
    • generic



        Name: erR10175 Date: 06/17/2004



          The following method of the class javax.xml.datatype.DatatypeFactory

        public abstract Duration newDurationDayTime(boolean isPositive, BigInteger day,
                    BigInteger hour, BigInteger minute, BigInteger second)

        throws NullPointerException if the 'second' parameter is null.
        Null value of other BigInteger parameters are processed without exceptions.

        According to the javadoc of the method, NPE may not be thrown from the method.

        The bug is found in jdk15-b55 and in jaxp13-b19.

        The bug affects the following new JAXP TCK 1.3 test:

          api/javax_xml/datatype/DatatypeFactory/index.html#Duration[NewDurationDayTime004]

        To reproduce the bug compile and run the following code as shown in the log below.
        --------------------------- test.java
        import java.math.BigInteger;
        import javax.xml.datatype.DatatypeFactory;
        import javax.xml.datatype.Duration;

        class test {
            public static void main(String [] args) throws Exception {
                BigInteger one = new BigInteger("1");
                DatatypeFactory df = DatatypeFactory.newInstance();
                BigInteger [] values = {null, one};
                for(int d = 0; d <= 1; ++d) { for(int h = 0; h <= 1; ++h) {
                for(int m = 0; m <= 1; ++m) { for(int s = 0; s <= 1; ++s) {
                    try {
                        df.newDurationDayTime(true, values[d], values[h], values[m], values[s]);
                    } catch (NullPointerException e) {
                        System.out.println("Failed: newDurationDayTime(true, " + values[d] + ", "
                                         + values[h] + ", " + values[m] + ", " + values[s] + ")");
                    } catch (IllegalStateException e) {
                    }
                } } } }
            }
        }
        -------------------------------------

        --------------------------------- log
        $javac test.java && java -showversion -cp . 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)

        Failed: newDurationDayTime(true, null, null, null, null)
        Failed: newDurationDayTime(true, null, null, 1, null)
        Failed: newDurationDayTime(true, null, 1, null, null)
        Failed: newDurationDayTime(true, null, 1, 1, null)
        Failed: newDurationDayTime(true, 1, null, null, null)
        Failed: newDurationDayTime(true, 1, null, 1, null)
        Failed: newDurationDayTime(true, 1, 1, null, null)
        Failed: newDurationDayTime(true, 1, 1, 1, null)
        -------------------------------------

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

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

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: