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

Timer.schedule throws IllegalArgumentException for time (Long.MAX_VALUE)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000



      Name: jl125535 Date: 07/09/2003


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]
      HP-UX lmn1 B.11.00 A 9000/800 143901507 two-user license

      Reproduced with J2SE 1.4.2 on Solaris 8.

      A DESCRIPTION OF THE PROBLEM :
      Timer.schedule() throws IllegalArgumentException with Long.MAX_VALUE for a delay. The relevant javadoc is at http://java.sun.com/j2se/1.4.1/docs/api/java/util/Timer.html#schedule(java.util.TimerTask,%20long,%20long).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the code supplied.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Timer should schedule.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.IllegalArgumentException: Illegal execution time.
              at java.util.Timer.sched(Timer.java:308)
              at java.util.Timer.schedule(Timer.java:180)
              at TimerIssue.main(TimerIssue.java:8)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Timer;
      import java.util.TimerTask;

      public class TimerIssue {
          public static void main(String args[]) {
              Timer t = new Timer();
              // throws java.lang.IllegalArgumentException: Illegal execution time.
              t.schedule(new MyTask(), Long.MAX_VALUE, 1000);
          }

          public static class MyTask extends TimerTask {
              public void run() {
                  System.out.println("task is running...");
              }
          }
      }
      ---------- END SOURCE ----------
      (Review ID: 185360)
      ======================================================================

            jjb Josh Bloch (Inactive)
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: