JDK-8301940 : SwingWorker calls 'done' before the 'doInBackground' is finished
  • Type: CSR
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P4
  • Status: Closed
  • Resolution: Withdrawn
  • Fix Versions: tbd
  • Submitted: 2023-02-07
  • Updated: 2023-02-10
  • Resolved: 2023-02-10
Related Reports
CSR :  
Description
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.



Comments
[~aivanov] please review the CSR
07-02-2023