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

forkjoin tasks interrupted after shutdown

    Details

      Description

      FULL PRODUCT VERSION :
      java 10 2018-03-20

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.334]

      A DESCRIPTION OF THE PROBLEM :
      java.lang.InterruptedException from "pool.awaitTermination(10, TimeUnit.MINUTES" not waiting

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Wait for 10 minutes or until all threads complete with:

      pool.awaitTermination(10, TimeUnit.MINUTES);
      ACTUAL -
      java.lang.InterruptedException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      WARNING: Using incubator modules: jdk.incubator.httpclient
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
      java.lang.InterruptedException
      at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:385)
      at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:402)
      at jdk.incubator.httpclient/jdk.incubator.http.HttpClientFacade.send(HttpClientFacade.java:101)
      at Java10Bug/Main.Main.run(Main.java:43)
      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package Main;

      import jdk.incubator.http.HttpClient;
      import jdk.incubator.http.HttpRequest;
      import jdk.incubator.http.HttpResponse;

      import java.net.URI;
      import java.util.concurrent.ExecutorService;
      import java.util.concurrent.Executors;
      import java.util.concurrent.TimeUnit;

      public class Main implements Runnable {

          private static HttpClient client = HttpClient.newHttpClient();

          public static void main(String[] args) {
              ExecutorService pool = Executors.newWorkStealingPool(10);

              for (int i = 1; i <= 10; i++) {
                  pool.submit(new Main());
              }

              /*
              try {
                  TimeUnit.SECONDS.sleep(10); // Wait 10 seconds for threads to finish
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              */

              try {
                  pool.shutdown();
                  pool.awaitTermination(10, TimeUnit.MINUTES);
              } catch (Exception e) {
                  System.err.println("Exception: " + e);
              } finally {
                  pool.shutdownNow();
              }
          }

          public void run() {
              try {
                  HttpResponse<String> response1 = client.send(HttpRequest.newBuilder()
                          .uri(new URI("https://lolnames.gg/en/"))
                          .build(), HttpResponse.BodyHandler.asString());
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }


      -------- module-info.java ---------

      module Java10Bug {
          requires jdk.incubator.httpclient;
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      In the source code uncomment the sleep between /* */ and it works

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: