Hello,

I develop a small client program for visualizing and recording the readings of temperature and humidity sensors with arduino + DHT22. Made GUI - using JavaFX. But I ran into a problem, sometimes JavaFX exceptions may occur when recording readings for more than one hour, I am new to Java, google that there may be an error in using the same object from different streams BUT I have one write and draw stream. I write data to XLS (Excel) using Apache POI. I attach the entire listing of the program, as well as the exception log. Who can tell which way to dig? At what stage I get exceptions, I can’t find it because the program runs for several hours and Exception crashes at any time.

The project itself on gita + sorsy: https://github.com/mozomig/Java-GUI-Serial-port-Arduino

Exception LOG:

Exception in thread "JavaFX Application Thread" java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:386) at java.util.AbstractList$Itr.next(AbstractList.java:355) at com.sun.javafx.scene.shape.PathUtils.configShape(PathUtils.java:45) at javafx.scene.shape.Path.impl_configShape(Path.java:251) at javafx.scene.shape.Path.impl_configShape(Path.java:89) at javafx.scene.shape.Shape.impl_computeGeomBounds(Shape.java:864) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.updateTxBounds(Node.java:3641) at javafx.scene.Node.getTransformedBounds(Node.java:3424) at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) at javafx.scene.Parent.recomputeBounds(Parent.java:1524) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.updateTxBounds(Node.java:3641) at javafx.scene.Node.getTransformedBounds(Node.java:3424) at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) at javafx.scene.Parent.updateCachedBounds(Parent.java:1596) at javafx.scene.Parent.recomputeBounds(Parent.java:1535) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.computeLocalBounds(Node.java:3593) at javafx.scene.Node.updateLocalBounds(Node.java:3623) at javafx.scene.Node.getLocalBounds(Node.java:3484) at javafx.scene.Node.updateTxBounds(Node.java:3641) at javafx.scene.Node.getTransformedBounds(Node.java:3424) at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) at javafx.scene.Parent.recomputeBounds(Parent.java:1524) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.updateTxBounds(Node.java:3641) at javafx.scene.Node.getTransformedBounds(Node.java:3424) at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) at javafx.scene.Parent.updateCachedBounds(Parent.java:1596) at javafx.scene.Parent.recomputeBounds(Parent.java:1535) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.updateTxBounds(Node.java:3641) at javafx.scene.Node.getTransformedBounds(Node.java:3424) at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) at javafx.scene.Parent.recomputeBounds(Parent.java:1524) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.impl_intersectsBounds(Node.java:5013) at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931) at javafx.scene.Node.impl_pickNode(Node.java:4912) at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899) at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485) at javafx.scene.Scene.pick(Scene.java:1942) at javafx.scene.Scene.access$6700(Scene.java:159) at javafx.scene.Scene$MouseHandler.process(Scene.java:3711) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene$MouseHandler$1.run(Scene.java:3521) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.ArrayList.elementData(ArrayList.java:418) at java.util.ArrayList.get(ArrayList.java:431) at javafx.scene.Parent.updateCachedBounds(Parent.java:1591) at javafx.scene.Parent.recomputeBounds(Parent.java:1535) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.updateTxBounds(Node.java:3641) at javafx.scene.Node.getTransformedBounds(Node.java:3424) at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) at javafx.scene.Parent.recomputeBounds(Parent.java:1524) at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) at javafx.scene.Node.updateGeomBounds(Node.java:3577) at javafx.scene.Node.getGeomBounds(Node.java:3530) at javafx.scene.Node.getLocalBounds(Node.java:3478) at javafx.scene.Node.impl_intersectsBounds(Node.java:5013) at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931) at javafx.scene.Node.impl_pickNode(Node.java:4912) at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899) at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485) at javafx.scene.Scene.pick(Scene.java:1942) at javafx.scene.Scene.access$6700(Scene.java:159) at javafx.scene.Scene$MouseHandler.process(Scene.java:3711) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene$MouseHandler$1.run(Scene.java:3521) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException 

  • 3
    According to the error, you are somewhere in the cycle running through the collection and trying to change the collection in the same cycle. You can not do it this way. You need to either make a change to a separate collection or work through the Iterable interface - YuriSP
  • Are you sure that serialPortEvent comes in the stream you are expecting, i.e. JavaFX Application Thread . Check with Thread.currentThread().getName() - Andrey M

0