The invincible ConcurrentModificationException

Randahl Fink Isaksen randahl at rockit.dk
Mon Apr 15 04:23:54 PDT 2013


For several weeks I have been battling a ConcurrentModificationException which I keep getting from JavaFX. I would be really grateful if anyone have any ideas to share, so here is a brief description of my problem.

My use case is pretty simple. I have a pane which shows a number of rows of TextFields containing e-mail addresses, and next to each e-mail address is an add button which the user can click to add an additional empty row, where the user can type in another e-mail address.

This is trivial stuff, but here is the catch: When I click my add button, I get the ConcurrentModificationException shown below this e-mail.

My problem here is, the stack trace shows mostly JavaFX code. Most of the stack trace is about handling the mouse click event. Then, my handler for the button click is invoked (shown in bold), and all I do is a simple 

emailPane.getChildren().add(myNewRow)

and JavaFX blows up. I am truly puzzled. I am on the JavaFX thread, so how can adding a node to the scene lead to a ConcurrentModificationException? I mean, there is only one single thread, so in my view, there is no way this could happen. Only… it does actually happen.

Any ideas are truly welcomed

Thanks

Randahl



Exception in thread "JavaFX Application Thread" java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
	at java.util.ArrayList$Itr.next(ArrayList.java:791)
	at com.sun.javafx.collections.ObservableListWrapper$ObservableListIterator.next(ObservableListWrapper.java:681)
	at com.sun.javafx.collections.VetoableObservableList$VetoableObservableListIterator.next(VetoableObservableList.java:328)
	at javafx.scene.Parent.computeDirtyScene(Parent.java:597)
	at javafx.scene.Parent.sceneChanged(Parent.java:612)
	at javafx.scene.Node$4.invalidated(Node.java:699)
	at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:129)
	at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163)
	at javafx.scene.Node.setScene(Node.java:661)
	at javafx.scene.Parent$1.onChanged(Parent.java:425)
	at com.sun.javafx.collections.VetoableObservableList.callObservers(VetoableObservableList.java:83)
	at com.sun.javafx.collections.ObservableListWrapper.add(ObservableListWrapper.java:154)
	at com.sun.javafx.collections.VetoableObservableList.add(VetoableObservableList.java:167)
	at com.intuism.ui.form.set.SetViewer.readItem(SetViewer.java:55)
	at com.intuism.ui.form.set.SetEditor$2.handle(SetEditor.java:128)
	at com.intuism.ui.form.set.SetEditor$2.handle(SetEditor.java:123)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
	at javafx.event.Event.fireEvent(Event.java:171)
	at javafx.scene.Node.fireEvent(Node.java:6863)
	at javafx.scene.control.Button.fire(Button.java:179)
	at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
	at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
	at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
	at javafx.event.Event.fireEvent(Event.java:171)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3328)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3168)
	at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3123)
	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)
	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2265)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
	at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
	at com.sun.glass.ui.View.notifyMouse(View.java:922)


More information about the openjfx-dev mailing list