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

SwingWorker calls 'done' before the 'doInBackground' is finished

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Withdrawn
    • Icon: P4 P4
    • tbd
    • client-libs
    • None
    • behavioral
    • medium
    • Might pose problem to application which is implemented w.r.t wrong spec
    • Java API
    • SE

      Summary

      SwingWorker spec is ambiguous in some parts with regards to sequence of execution being performed, which is now being rectified.

      Problem

      The order of execution mentioned in the class description was wrong with respect to the spec mentioned in the code. It was ambiguous as to when done method will be called, when state will be changed to DONE etc

      Solution

      Along with code rectification of done method being called AFTER doInBackground as is described in the spec, the wording is also recitified to clarify done will be called at the end after doInBackground is finished and state changed to DONE

      Specification

      javax.swing.SwingWorker

        * <p>
        * Before the {@code doInBackground} method is invoked on a <i>worker</i> thread,
        * {@code SwingWorker} notifies any {@code PropertyChangeListeners} about the
        * {@code state} property change to {@code StateValue.STARTED}.  After the
      - * {@code doInBackground} method is finished the {@code done} method is
      - * executed.  Then {@code SwingWorker} notifies any {@code PropertyChangeListeners}
      - * about the {@code state} property change to {@code StateValue.DONE}.
      + * {@code doInBackground} method is finished, {@code SwingWorker} notifies
      + * any {@code PropertyChangeListeners} about the {@code state} property
      + * change to {@code StateValue.DONE}. Finally, {@code done} method is executed.
        *
        * <p>
        * {@code SwingWorker} is only designed to be executed once.  Executing a
        * {@code SwingWorker} more than once will not result in invoking the
        * {@code doInBackground} method twice.

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: