On Wed, 15 Apr 2026 20:53:01 GMT, Alexander Zuev <[email protected]> wrote:

> When the test ends - all dialogs are being closed and all parents were 
> dsposed because they were created once, not in cycle. 

That's not what I see.  The code is this (with irrelevancies removed)

      try {
            for (DialogOwner owner: DialogOwner.values()) {
                EventQueue.invokeLater(() -> { createGUI(owner); });   
            }

        } finally {
            EventQueue.invokeAndWait(this::closeAll);
        }

So every loop iteration calls createGUI() and each call stores "dialog", yet 
closeAll is called only once at the end, outside the loop at the end.

If we moved closeAll inside the loop that would be enough.
Although it also seems that the variables should be nulled out after being 
disposed and probably should be 'volatiie'

Also, it suggests that on Windows & Linux these dialogs are being disposed 
automatically - somehow.

 
I've run one of the tests locally and what I found this this -
 

Specifically the case that prevents the app from exiting is this -
dialog = new TestDialog((Dialog) null);

What happens is this
- there's only one loop that creates parentDialog
- there's only one loop that creates parentFrame
- the last loop uses a null frame, but when we enter closeAll() 'dialog' points 
to this

In the cases that have a "parent" , when the parent is disposed in closeAll() 
then the child is disposed, in the null frame case, 'dialog' is disposed.

That leaves the 'null dialog' parent loop that is lost.
It is the ONE dialog that remains and causes the test to not exit.

To fix this test you only need one line 

--- a/test/jdk/java/awt/Modal/ModalBlockingTests/UnblockedDialogTest.java
+++ b/test/jdk/java/awt/Modal/ModalBlockingTests/UnblockedDialogTest.java
@@ -108,6 +108,7 @@ public void doTest() throws Exception {
 
                 dialog.checkUnblockedDialog(robot, "");
                 robot.waitForIdle(delay);
+                dialog.dispose();
             }


although properly you should do what I wrote above and invoke closeAll on every 
loop

-------------

PR Comment: https://git.openjdk.org/jdk/pull/30729#issuecomment-4271642526

Reply via email to