java.util.ConcurrentModificationException

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
MarkM
Posts: 2
Joined: Thu Jul 19, 2012 8:19 am
antibot: No, of course not.

java.util.ConcurrentModificationException

Post by MarkM » Thu Jul 19, 2012 8:36 am

Hi,

I implemented jfreechart into an application. It seems that everthing runs fine, but several times I got the following exeption:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
	at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
	at java.util.AbstractList$Itr.next(Unknown Source)
	at org.jfree.chart.plot.MeterPlot.draw(MeterPlot.java:874)
	at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1237)
	at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1677)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintToOffscreen(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
	at javax.swing.RepaintManager.paint(Unknown Source)
	at javax.swing.JComponent._paintImmediately(Unknown Source)
	at javax.swing.JComponent.paintImmediately(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.access$700(Unknown Source)
	at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
I´m not using any threads - beside the EventDispatchThread for the frame... Any idea how i could get rid of this exception?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: java.util.ConcurrentModificationException

Post by John Matthews » Thu Jul 19, 2012 10:33 am

Don't modify the List except via the remove() method of the Iterator or ListIterator, as mentioned here.

MarkM
Posts: 2
Joined: Thu Jul 19, 2012 8:19 am
antibot: No, of course not.

Re: java.util.ConcurrentModificationException

Post by MarkM » Thu Jul 19, 2012 11:36 am

Hi John,

I only change the Meterplot with the following methods:

setvalue()
=> to set the actual value

clearIntervals()
addInterval()
=> to clear the interval and set two new intervals (the intervals change in addiction to the actual value)

There is no other way I make changes to the data....

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: java.util.ConcurrentModificationException

Post by John Matthews » Fri Jul 20, 2012 2:28 am

An sscce might help isolate the problem, but intermittent failure suggests incorrect synchronization.

Locked