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

SwingWorker.get does not throw InterruptedException

XMLWordPrintable

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

      When worker thread in doInBackground method is interrupted then worker.get throws ExecutionException whereas the spec state that InterruptedException should be thrown.
      You may reproduce it with usage of the following code:
      ------------
      import javax.swing.*;
      import java.util.concurrent.ExecutionException;

      public class Test {
          public static void main(String[] args) throws ExecutionException, InterruptedException {
              SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
                  protected Void doInBackground() throws InterruptedException {
                      Thread.currentThread().interrupt();
                      Thread.sleep(100);
                      return null;
                  }
              };

              worker.execute();
              Thread.sleep(100);
              worker.get();
          }
      }
      -------

            idk Igor Kushnirskiy (Inactive)
            ydanilev Yury Danilevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: