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

SwingWorker.get throws CancellationException

XMLWordPrintable

    • 6
    • b19
    • generic, x86
    • generic, windows_vista

        SwingWorker.get sometimes throws CancellationException if the cancel method has been invoked. To reproduce it use the following test:
        ---------------
        import javax.swing.*;
        import java.util.concurrent.ExecutionException;

        public class Test {
            public static void main(String[] args) throws InterruptedException, ExecutionException {
                SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
                    protected Void doInBackground() throws InterruptedException {
                        while (true);
                    }
                };

                worker.execute();
                Thread.sleep(500);
                worker.cancel(true);
                worker.get();
            }
        }
        -----------

        The spec doesn't mention CancellationException so this behavior is unpredicatable.

              serb Sergey Bylokhov
              ydanilev Yury Danilevich (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: