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

ScheduledExecutorService do not rerun if job throws NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6u25
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_24"
      Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
      Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Using the ScheduledExecutorService.scheduleAtFixedRate, if the run method of the Runnable throws a NullPointerException, the run is stops being called.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run attached test code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should output "Running 1" every one second.
      ACTUAL -
      Outputs "Running 1" once and never again.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.concurrent.Executor;
      import java.util.concurrent.ExecutorService;
      import java.util.concurrent.Executors;
      import java.util.concurrent.ScheduledExecutorService;
      import java.util.concurrent.TimeUnit;

      /**
       *
       */
      public class Main {


          private static void test1() {

              ScheduledExecutorService exe = Executors.newScheduledThreadPool(1);
              exe.scheduleAtFixedRate(new Runnable() {

                  @Override
                  public void run() {
                      System.out.println("Running 1");
                      //Integer x = null;
                      //x.floatValue();
                  }
              }, 1, 1, TimeUnit.SECONDS);

          }



          public static void main(String[] args) {
              try {
                  test1();
              } catch (Exception e) {
                  e.printStackTrace();
              }

          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Wrapping the guts of my run method with try { } catch (Throwable t) { }

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: