The invincible ConcurrentModificationException
Randahl Fink Isaksen
randahl at rockit.dk
Mon Apr 15 09:42:06 PDT 2013
After the many helpful comments I have received today, I can now confirm the problem is now solved. What happened was:
1. I added a node containing child nodes to the scene
2. JavaFX set the scene property of the node and its child nodes
3. In of my nodes I was listening for the scene property and upon receiving the scene I was adding an additional child node
4. JavaFX blew up, since the version of JavaFX I am using is still sensitive to the addition of child nodes from scene property listeners.
I am glad that Richard agrees this should be solved, and I have created Jira issue https://javafx-jira.kenai.com/browse/RT-28901.
Thank you everyone for the comments
Randahl
On Apr 15, 2013, at 16:42 , Richard Bair <Richard.Bair at oracle.com> wrote:
> Right, what it looks like is that during the event delivery phase we are iterating over the children. One of the "stops" along our iteration is to invoke your code, which then modifies the list of children, which then blows up when we attempt to take the next step in the iteration. This is most definitely a bug in our code (we will need to make a copy of the children prior to iterating), but also presents a challenge (because for performance reasons making all those copies will be painful).
>
> Richard
>
> On Apr 15, 2013, at 4:52 AM, Tom Eugelink <tbee at tbee.org> wrote:
>
>>
>> To my knowledge single threading does not prevent CME's; it is very possible that, while the threat is iterating over a list, it enters some method that modifies the list. That would also invoke a CME.
>>
>> Tom
>>
>>
>> On 2013-04-15 13:23, Randahl Fink Isaksen wrote:
>>> 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