JDK-6309616 : Inconsistency between showing modal dialog on EDT and another thread
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-08-11
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b02Fixed
Related Reports
Relates :  
Relates :  
Description
Examine the following situation:  there is a code that shows a modal dialog.  It contains Button, which has an action listener, which does two things:
calls hide on the modal dialog; set the value of the result (shared variable).  If the modal dialog was shown from EDT, you will see the set value right after the return from dialog's show method.  If modal dialog was shown from another thread, you will not see the value.

This happens because when a modal dialog is shown from non-EDT thread, it block that thread by waiting for some condition.  When hide is called this condition is set, so blocked thread continues execution.  However, modal dialog is still being process on EDT - pump is still running, event listener code is still being executed.   This causes some problems to Swing (see 6308815) and is an inconsistency.  

Ideally, we would need to wait for exit from pump before setting the condition which unblocks waiting thread.  This is a proposed solution.
I have attached a test that can be used to demonstrate the problem. In the test a dialog is shown with a button in it. When the button is clicked, the dialog is hidden and a value of some property is printed in the system console. If the value is 'false', the bug is reproduced.

Comments
EVALUATION If the modal dialog is shown from non-EDT thread T1 and is hidden in some method on another thread, then we should wait that method to finish and unblock the calling thread T1 after that. This behaviour is consistant with the case when the dialog is shown from EDT.
13-09-2005