JDK-6987896 : Modal dialogs resumes the calling thread before it's hidden
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,linux_redhat_5.0,solaris,windows,windows_xp,windows_7 generic,linux_redhat_5.0,solaris,windows,windows_xp,windows_7
  • CPU: generic,x86
  • Submitted: 2010-09-28
  • Updated: 2012-03-22
  • 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 b114Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
Execute the following simple test:

import java.awt.*;

public class slash {
  public static void main(String[] args) {
    FileDialog fd = new FileDialog((Frame)null, "save", FileDialog.SAVE);
    fd.setVisible(true);
    System.err.println("dir: " + fd.getDirectory());
  }
}

Note that the dialog is modal, so System.err.println() should be executed after the dialog is hidden/disposed. However, even if the dialog is still visible, the current directory is printed to console in ~5 secs after the dialog is shown.

Comments
SUGGESTED FIX diff -r d21c9804c512 src/share/classes/java/awt/Dialog.java --- a/src/share/classes/java/awt/Dialog.java Mon Sep 27 17:38:57 2010 +0400 +++ b/src/share/classes/java/awt/Dialog.java Tue Sep 28 14:15:56 2010 +0400 @@ -1068,7 +1068,7 @@ modalityPushed(); try { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); - secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000); + secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0); if (!secondaryLoop.enter()) { secondaryLoop = null; }
28-09-2010

EVALUATION The fix for 6949936 included the following line in Dialog.java: secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000); but it should be secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0); to indicate that the secondary event loop should not be auto-exited. *** (#1 of 1): [ UNSAVED ] ###@###.###
28-09-2010