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

ForkJoinPool:schedule(*) does not throw RejectedExecutionException when pool is shutdown

XMLWordPrintable

      As per the spec :
      https://download.java.net/java/early_access/jdk25/docs/api/java.base/java/util/concurrent/ForkJoinPool.html#schedule(java.lang.Runnable,long,java.util.concurrent.TimeUnit)

      RejectedExecutionException - if the pool is shutdown or submission encounters resource exhaustion.

      A sample code below
      ===
      try (final ForkJoinPool p = new ForkJoinPool(1)) {
                  Runnable task = () -> {
                  };
                  p.shutdown();
                  p.awaitTermination(2000, MILLISECONDS);
                  assertTrue(p.isShutdown());
                  Assert.assertThrows(() -> p.schedule(task, 2000, MILLISECONDS), RejectedExecutionException.class);
              }

      ===
      expected to throw RejectedExecutionException,

      Actual : java.lang.IllegalStateException

      java.lang.IllegalStateException
      at java.base/jdk.internal.vm.SharedThreadContainer.start(SharedThreadContainer.java:146)
      at java.base/java.util.concurrent.ForkJoinPool.startDelayScheduler(ForkJoinPool.java:3468)
      at java.base/java.util.concurrent.ForkJoinPool.scheduleDelayedTask(ForkJoinPool.java:3492)


            vklang Viktor Klang
            kganapureddy Krushnareddy Ganapureddy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: