问题
Very rarely, when showing a modal dialog in a Java Swing application using JDK1.8.0_144
, the whole application gets frozen.
I couldn't find a relevant bug in the JDK bug database. The only one that would seem remotely related is this one but our application was never minimized whenever it got frozen.
I caught it once in debug and it seems that events are still being processed by the secondary loop (focus events, mouse movement events) but the modal dialog cannot be closed and the user cannot interact with the application.
Obviously my first thought was to update the JDK version but since I could only rarely reproduce the issue I won't be sure if it fixes the issue or not.
Anyone had this happen to them or do you have any suggestion on how to debug or fix?
WARN[09:41:41,482] - SwingCheckerTimer - stacktrace - AWT-EventQueue-0, Id = 22, Priority = 6: WAITING
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.awt.EventQueue.getNextEvent(EventQueue.java:608)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:170)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
java.awt.SequencedEvent.dispatch(SequencedEvent.java:107)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
java.awt.EventQueue.access$500(EventQueue.java:97)
java.awt.EventQueue$3.run(EventQueue.java:709)
java.awt.EventQueue$3.run(EventQueue.java:703)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
java.awt.EventQueue$4.run(EventQueue.java:731)
java.awt.EventQueue$4.run(EventQueue.java:729)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:184)
java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:229)
java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:227)
java.security.AccessController.doPrivileged(Native Method)
java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:227)
java.awt.Dialog.show(Dialog.java:1084)
java.awt.Component.show(Component.java:1671)
java.awt.Component.setVisible(Component.java:1623)
java.awt.Window.setVisible(Window.java:1014)
java.awt.Dialog.setVisible(Dialog.java:1005)
来源:https://stackoverflow.com/questions/48676282/java-modal-dialog-freezes-whole-application-when-using-jdk-8