<div dir="ltr"><div>All,</div><div><br></div><div>I have a strange issue popping up once in a while.</div><div>I have an application (FXML+ Controller) that has a "new" button opening a new window. In 99% percent of the cases this works just fine.</div><div><br></div><div>In some rare cases though, stage.show() fails due to a ConcurrentModificationException. Since this issue does not happen in my code but rather in JavaFX code I wanted to ask whether there is a specific prerequisite I am not aware of or whether this is a bug in JavaFX.</div><div><br></div><div>Attached the stack trace. Unfortunately I am not able to create a reproducible example that fails 
always.</div><div><br></div><div>I am grateful for any tip.</div><div><br></div><div>Thanks,</div><div><br></div><div>-- Daniel</div><div><br></div><div><br></div><div>Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException<br>   at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)<br>  at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)<br>   at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)<br>    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)<br>       at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)<br>       at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)<br>      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)<br>    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)<br>        at javafx.event.Event.fireEvent(Event.java:198)<br>       at javafx.scene.Node.fireEvent(Node.java:8797)<br>        at javafx.scene.control.Button.fire(Button.java:203)<br>  at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)<br>        at com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)<br>   at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)<br>    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)<br>    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)<br>       at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)<br>       at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)<br>      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)<br>      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)<br> at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)<br>    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)<br>        at javafx.event.Event.fireEvent(Event.java:198)<br>       at javafx.scene.Scene$MouseHandler.process(Scene.java:3881)<br>   at javafx.scene.Scene.processMouseEvent(Scene.java:1874)<br>      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2607)<br>   at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)<br> at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)<br> at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)<br>   at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)<br>  at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)<br>     at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)<br>   at com.sun.glass.ui.View.handleMouseEvent(View.java:551)<br>      at com.sun.glass.ui.View.notifyMouse(View.java:937)<br>   at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)<br>        at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)<br>      at java.base/java.lang.Thread.run(Thread.java:833)<br>Caused by: java.lang.reflect.InvocationTargetException<br>    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)<br>   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>   at java.base/java.lang.reflect.Method.invoke(Method.java:568)<br> at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)<br>       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)<br>   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>   at java.base/java.lang.reflect.Method.invoke(Method.java:568)<br> at com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)<br>      at com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)<br>      at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1854)<br>  ... 50 more<br>Caused by: java.util.ConcurrentModificationException<br>     at java.base/java.util.AbstractList$Itr.checkForComodification(AbstractList.java:399)<br> at java.base/java.util.AbstractList$Itr.next(AbstractList.java:368)<br>   at javafx.scene.control.skin.MenuBarSkin.updateActionListeners(MenuBarSkin.java:810)<br>  at javafx.scene.control.skin.MenuBarSkin.updateActionListeners(MenuBarSkin.java:811)<br>  at javafx.scene.control.skin.MenuBarSkin.rebuildUI(MenuBarSkin.java:1017)<br>     at javafx.scene.control.skin.MenuBarSkin.<init>(MenuBarSkin.java:356)<br>   at javafx.scene.control.MenuBar.createDefaultSkin(MenuBar.java:202)<br>   at javafx.scene.control.Control.doProcessCSS(Control.java:899)<br>        at javafx.scene.control.Control$1.doProcessCSS(Control.java:89)<br>       at com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67)<br>   at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)<br>    at javafx.scene.Parent.doProcessCSS(Parent.java:1400)<br> at javafx.scene.Parent$1.doProcessCSS(Parent.java:125)<br>        at com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)<br>     at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)<br>    at javafx.scene.Parent.doProcessCSS(Parent.java:1400)<br> at javafx.scene.Parent$1.doProcessCSS(Parent.java:125)<br>        at com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)<br>     at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)<br>    at javafx.scene.Parent.doProcessCSS(Parent.java:1400)<br> at javafx.scene.Parent$1.doProcessCSS(Parent.java:125)<br>        at com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)<br>     at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)<br>    at javafx.scene.Node.processCSS(Node.java:9477)<br>       at javafx.scene.Scene.doCSSPass(Scene.java:572)<br>       at javafx.scene.Scene.preferredSize(Scene.java:1770)<br>  at javafx.scene.Scene$2.preferredSize(Scene.java:396)<br> at com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66)<br>        at javafx.stage.Window$12.invalidated(Window.java:1163)<br>       at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)<br>        at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)<br>        at javafx.stage.Window.setShowing(Window.java:1239)<br>   at javafx.stage.Window.show(Window.java:1254)<br> at javafx.stage.Stage.show(Stage.java:277)<br>    at com.foo.MainLayoutController.openNewWindow(MainLayoutController.java:3851)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>