Each time the ToolboxSignonHandler displays a password dialog, it leaks two AWT windows that it creates but does not call dispose() on, at the start of setupPasswordDialog(). I can see these windows living forever by calling java.awt.Window.getWindows(). These AWT windows each have native peers, so I expect that could see leaked handles in MS Windows if I had the tools.
For my application, I've written code which cleans these up when I might be exiting:
for (Window w : Window.getWindows()) {
Window[] ownedWindows = w.getOwnedWindows();
if (w instanceof PasswordDialog) {
log.info("Disposing leftover window {}", w);
w.dispose();
} else if (ownedWindows.length == 1 && ownedWindows[0] instanceof PasswordDialog) {
log.info("Disposing hidden parent {}", w);
w.dispose();
} else {
log.info("Unknown window {}", w);
}
}
After this runs, the application can exit when finished without my code needing to call System.exit() at the right time. However, these should really be disposed of by ToolboxSignonHandler, along with MessageDialog if a message is displayed.
I've confirmed with Nir Sofer's WinLister from http://www.nirsoft.net/utils/winlister.html that native window handles appear to be getting leaked as well. The attachment shows one normal AWT hidden window, and four leaked PasswordDialog windows, after prompting for a password twice.