Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent event in Graph: NoSuchElementException in GraphListeners #293

Closed
victornoel opened this issue Aug 10, 2018 · 14 comments · Fixed by #337
Closed

Concurrent event in Graph: NoSuchElementException in GraphListeners #293

victornoel opened this issue Aug 10, 2018 · 14 comments · Fixed by #337

Comments

@victornoel
Copy link

Hi,

I have a Graph, Nodes and Edges that are concurrently modified.

Since the Graph is attached to a Viewer, GraphListeners is responsible of piping the events from the graph to the viewer.

Sometimes, when there are concurrent modification of the elements of the graph, I get the following exception:

java.util.NoSuchElementException
	at java.util.LinkedList.removeFirst(LinkedList.java:270)
	at java.util.LinkedList.remove(LinkedList.java:685)
	at org.graphstream.stream.SourceBase.manageEvents(SourceBase.java:872)
	at org.graphstream.stream.SourceBase.sendAttributeChangedEvent(SourceBase.java:810)
	at org.graphstream.util.GraphListeners.sendAttributeChangedEvent(GraphListeners.java:73)
	at org.graphstream.graph.implementations.AbstractEdge.attributeChanged(AbstractEdge.java:106)
	at org.graphstream.graph.implementations.AbstractElement.addAttribute(AbstractElement.java:544)
	at org.graphstream.graph.implementations.AbstractElement.setAttribute(AbstractElement.java:560)

I tried using Graphs.synchronizedGraph but it doesn't solve the problem, because this is not about concurrent modification of ONE element, but concurrent emission of events to theGraphListeners.

There seem to be no way to have this pipe behave correctly with concurrence.
Is there something I am missing or is this a bug?

@jeremy-boes
Copy link

We forgot to mention we are using v1.3.

@mdvx
Copy link

mdvx commented Feb 4, 2020

I am hitting the same issue, my background thread is replacing attributes on the Graph, which works fine until i hit this. Then the Graph stops updating on the screen.

@hichbra
Copy link
Contributor

hichbra commented Feb 4, 2020

Hi,

Can you confirm that this problem still exists in Graphstream 2.0 ?
Also, to be able to work in that problem, can you provide a simple and self contained example ?

@jeremy-boes
Copy link

Could you upload 2.0 to Maven Central so I can test it?

@hichbra
Copy link
Contributor

hichbra commented Feb 10, 2020

Graphstream 2 use jitpack.io, you can see how to use it in the readme.

@jeremy-boes
Copy link

A similar exception occurs with Graphstream 2.0 (gs-core 2.0.0-beta, gs-ui-swing 2.0-alpha)

Unfortunately, I'm unable to spend more time on this right now and provide a self-contained example.

Here's the complete stacktrace:

Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
	at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1493)
	at java.base/java.util.HashMap$ValueIterator.next(HashMap.java:1521)
	at org.graphstream.ui.graphicGraph.StyleGroup$BulkIterator.next(StyleGroup.java:815)
	at org.graphstream.ui.graphicGraph.StyleGroup$BulkIterator.next(StyleGroup.java:772)
	at java.base/java.lang.Iterable.forEach(Iterable.java:74)
	at org.graphstream.ui.swing.renderer.StyleRenderer.render(StyleRenderer.java:92)
	at org.graphstream.ui.swing.renderer.StyleRenderer.render(StyleRenderer.java:67)
	at org.graphstream.ui.swing.SwingGraphRenderer.lambda$null$4(SwingGraphRenderer.java:242)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.graphstream.ui.swing.SwingGraphRenderer.lambda$render$5(SwingGraphRenderer.java:240)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.graphstream.ui.swing.SwingGraphRenderer.render(SwingGraphRenderer.java:239)
	at org.graphstream.ui.swing.SwingGraphRenderer.render(SwingGraphRenderer.java:96)
	at org.graphstream.ui.swing_viewer.DefaultView.render(DefaultView.java:251)
	at org.graphstream.ui.swing_viewer.DefaultView.paintComponent(DefaultView.java:179)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
	at java.desktop/javax.swing.JLayeredPane.paint(JLayeredPane.java:590)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
	at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5262)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(RepaintManager.java:1643)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1618)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1556)
	at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1323)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1060)
	at java.desktop/java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
	at java.desktop/sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
	at java.desktop/sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
	at java.desktop/java.awt.Container.paint(Container.java:2002)
	at java.desktop/java.awt.Window.paint(Window.java:3940)
	at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:876)
	at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:848)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:848)
	at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:823)
	at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:772)
	at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1890)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

@hichbra
Copy link
Contributor

hichbra commented Feb 11, 2020

Thank you for the confirmation, I will try to work on this issue

@victornoel
Copy link
Author

@hichbra jitpack is missing the source artefacts for the latest versions, is there anyway for those to be available too?

@hichbra
Copy link
Contributor

hichbra commented Feb 13, 2020

I'm sorry if I misunderstood your question, are you talking about javafx ? There no beta version released for the moment.

@victornoel
Copy link
Author

@hichbra no, I'm talking about the maven source artefacts: https://maven.apache.org/plugin-developers/cookbook/attach-source-javadoc-artifacts.html

This is important when using a library that it is possible to explore its source code and not only depends on the binary jar.

@hichbra
Copy link
Contributor

hichbra commented Feb 13, 2020

Indeed ! Can you open a new issue ? We will try to work around for the next release.

@victornoel
Copy link
Author

@hichbra here it is: #336, thanks a lot :)

@hichbra
Copy link
Contributor

hichbra commented Feb 14, 2020

A pull request is sended : #337
if you want to try it in your project for a feedback :

<dependency>
 	<groupId>com.github.hichbra</groupId>
 	<artifactId>gs-core</artifactId>
 	<version>Fix293Concurrent-SNAPSHOT</version>
 	<scope>compile</scope>
</dependency>

@hichbra hichbra linked a pull request Feb 17, 2020 that will close this issue
pigne added a commit that referenced this issue Jul 16, 2020
@pigne pigne closed this as completed in 8585e80 Jul 16, 2020
@victornoel
Copy link
Author

@pigne sorry to disappoint, but I just tested with v2.0 (with the swing ui) and I still get the exception (but it seems it appears less often, while before it appeared every time).

Here is the current stacktrace:

java.util.NoSuchElementException
	at java.base/java.util.LinkedList.removeFirst(LinkedList.java:274)
	at java.base/java.util.LinkedList.remove(LinkedList.java:689)
	at org.graphstream.stream.SourceBase.manageEvents(SourceBase.java:841)
	at org.graphstream.stream.SourceBase.sendAttributeChangedEvent(SourceBase.java:825)
	at org.graphstream.util.GraphListeners.sendAttributeChangedEvent(GraphListeners.java:79)
	at org.graphstream.ui.graphicGraph.GraphicEdge.attributeChanged(GraphicEdge.java:216)
	at org.graphstream.graph.implementations.AbstractElement.setAttribute(AbstractElement.java:311)
	at org.graphstream.ui.graphicGraph.GraphicElement.setAttribute(GraphicElement.java:311)
	at org.graphstream.util.GraphListeners.edgeAttributeChanged(GraphListeners.java:166)
	at org.graphstream.ui.graphicGraph.GraphicGraph.edgeAttributeChanged(GraphicGraph.java:928)
	at org.graphstream.stream.SourceBase.sendAttributeChangedEvent(SourceBase.java:818)
	at org.graphstream.util.GraphListeners.sendAttributeChangedEvent(GraphListeners.java:79)
	at org.graphstream.graph.implementations.AbstractEdge.attributeChanged(AbstractEdge.java:105)
	at org.graphstream.graph.implementations.AbstractElement.setAttribute(AbstractElement.java:311)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants