#1034 IndexOutOfBoundsException with concurrent updates

1.0.x
closed
General (896)
5
2012-09-23
2011-03-19
No

First, thank you for this incredible project. I had just started writing my own when I found JFreeChart and swiftly trashed what I started for this.

Unto the main subject now :

I created a sample project to show JFreeChart (1.0.13 with JCommon 1.0.16) as a potential library and I found it throwing IndexOutOfBoundException once in a while. I provided the sample project and here is the stacktrace (note that the stacktrace does not contain any of the sample's class, so the problem does not lie in the sample). Also, the exception seems to be thrown at random (it is unpredictable to say when it will occur)

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 120, Size: 120
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.jfree.data.time.TimeSeries.getDataItem(TimeSeries.java:330)
at org.jfree.data.time.TimeSeriesCollection.getXValue(TimeSeriesCollection.java:421)
at org.jfree.chart.renderer.xy.XYLineAndShapeRenderer.drawSecondaryPass(XYLineAndShapeRenderer.java:1139)
at org.jfree.chart.renderer.xy.XYLineAndShapeRenderer.drawItem(XYLineAndShapeRenderer.java:925)
at org.jfree.chart.plot.XYPlot.render(XYPlot.java:3738)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3310)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1235)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1663)
at javax.swing.JComponent.paint(JComponent.java:1029)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1479)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1410)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:294)
at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:603)
at java.awt.EventQueue$1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Discussion

  • Yanick Rochon

    Yanick Rochon - 2011-03-19

    Sample project

     
  • David Gilbert

    David Gilbert - 2012-09-23

    JFreeChart is not thread-safe. Since the datasets will be read in the event dispatch thread while painting charts, you should keep all your dataset updates also on the event dispatch thread to avoid concurrent modification exceptions and other issues.

     
  • David Gilbert

    David Gilbert - 2012-09-23
    • assigned_to: nobody --> mungady
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks