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

SwingWorker.get throws CancellationException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
      6
    • Resolved In Build:
      b19
    • CPU:
      generic, x86
    • OS:
      generic, windows_vista

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: