JDK-6497929 : Modal dialogs are added to modalDialogs field several times
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2006-11-28
  • 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 6 JDK 7
6u10Fixed 7 b07Fixed
Related Reports
Duplicate :  
Relates :  
Description
Any modal dialog is added to the 'modalDialogs' static field of java.awt.Dialog class in modalShow() method. However, this method is called not only the dialog is really shown, but also when it is unblocked by another modal dialog. This leads to the situation when the dialog is added to the list of modal dialogs several times and prevents it from being GCed.

The test that can be used to demostrate the problem is attached.

Comments
EVALUATION After some discussion with the AWT team I decided to fix the problem with just moving 'modalDialogs.add(this)' and 'modalDialogs.remove(this)' out from modalShow() and modalHide(). I think this is a more correct solution than just to check if the dialog is already added to the list, because modalShow() and modalHide() methods are responsible only for windows blocking/unblocking, which can be called not only when a dialog is shown/hidden. At the same time 'modalDialogs' field is tightly related with the dialogs showing/hiding, so I suggest to remove it from modalShow()/modalHide().
29-11-2006

EVALUATION Modal dialogs should be tracked more carefully. For example, an additional check may be added to modalShow() to add the dialog to modalDialogs field only if it is not there yet, however there can a better solution.
28-11-2006