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

Duration.compare hangs on very long durations

XMLWordPrintable

    • 1.3
    • generic
    • generic
    • Verified

        Name: erR10175 Date: 12/25/2003


         
          The following methods of the class javax.xml.datatype.Duration hang-up
        if the durations are too long:

        public static int compare(Duration lhs, Duration rhs)
        public final boolean equals(Object rhs)
        public final boolean isLongerThan(Duration rhs)
        public final boolean isShorterThan(Duration rhs)

        Javadoc of the class does not specify that comparing algorithm my be time
        consuming for long durations. So all implementations should cope with all
        values in a reasonable time frame.

        This bug affects new tests in JCK 1.5 (not integrated yet)
            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]

        The bug is found in jdk1.5.0/beta/b32.

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

        public class test {
            public static void main(String [] args) {
                Duration duration1 = new Duration("P100000000000000000000D");
                Duration duration2 = new Duration("PT2400000000000000000000H");
                System.out.println("running compare('" + duration1
                                 + "', \'" + duration2 + "\') ...");
                System.out.println("returned " + Duration.compare(duration1, duration2));
            }
        }
        ----------------------------------------------------

        ------------------------------------------------ log
        $javac test.java && java -cp . -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

        running compare('P100000000000000000000D', 'PT2400000000000000000000H') ...
        ----------------------------------------------------

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



        -------------------------------------------------------
        I tried -> compare( Long.MAX_VALUE , Long.MAX_VALUE );
        did not return for 90 minutes and stopped

        ###@###.### 2004-01-06
        -------------------------------------------------------

              jsuttorsunw Jeff Suttor (Inactive)
              reysunw Rey Rey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: