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