JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report JPPF-503  -  JPPF Serialization: ConcurrentModificationException when serializing a java.util.Vector
Posted Jun 08, 2017 - updated Jun 11, 2017
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Closed
  • Assigned to
     lolo4j
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     lolo4j
  • Owned by
    Not owned by anyone
  • Category
    Core
  • Resolution
    RESOLVED
  • Priority
    Normal
  • Reproducability
    Always
  • Severity
    Normal
  • Targetted for
    icon_milestones.png JPPF 5.2.7
Issue description
Whern trying to serialize a Spring ApplicationContext using the JPPF serialization scheme, I get the following exception:
2017-06-08 08:02:07,204 [DEBUG][org.jppf.client.balancer.ChannelWrapperRemote.run(231)]: 
java.io.IOException
  at org.jppf.serialization.JPPFObjectOutputStream.writeObjectOverride(JPPFObjectOutputStream.java:91)
  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
  at org.jppf.serialization.DefaultJPPFSerialization.serialize(DefaultJPPFSerialization.java:58)
  at org.jppf.utils.ObjectSerializerImpl.serialize(ObjectSerializerImpl.java:79)
  at org.jppf.io.IOHelper.serializeDataToMemory(IOHelper.java:330)
  at org.jppf.io.IOHelper.serializeData(IOHelper.java:311)
  at org.jppf.io.IOHelper.sendData(IOHelper.java:283)
  at org.jppf.client.BaseJPPFClientConnection.sendTasks(BaseJPPFClientConnection.java:137)
  at org.jppf.client.JPPFClientConnectionImpl.sendTasks(JPPFClientConnectionImpl.java:34)
  at org.jppf.client.balancer.ChannelWrapperRemote$RemoteRunnable.run(ChannelWrapperRemote.java:212)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.ConcurrentModificationException
  at java.util.Vector$Itr.checkForComodification(Vector.java:1184)
  at java.util.Vector$Itr.next(Vector.java:1137)
  at org.jppf.serialization.VectorHandler.writeDeclaredFields(VectorHandler.java:49)
  at org.jppf.serialization.Serializer.writeFields(Serializer.java:179)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:146)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:122)
  at org.jppf.serialization.Serializer.writeDeclaredFields(Serializer.java:219)
  at org.jppf.serialization.Serializer.writeFields(Serializer.java:192)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:146)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:122)
  at org.jppf.serialization.Serializer.writeDeclaredFields(Serializer.java:219)
  at org.jppf.serialization.Serializer.writeFields(Serializer.java:192)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:146)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:122)
  at org.jppf.serialization.Serializer.writeDeclaredFields(Serializer.java:219)
  at org.jppf.serialization.Serializer.writeFields(Serializer.java:192)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:146)
  at org.jppf.serialization.Serializer.writeObject(Serializer.java:122)
  at org.jppf.serialization.JPPFObjectOutputStream.writeObjectOverride(JPPFObjectOutputStream.java:89)
  ... 12 more
The fix in VectorHandler appears to be simple; replace the line:
for (Object o: vector) serializer.writeObject(o);
with:
List<Object> list = new ArrayList<>(vector);
for (Object o: list) serializer.writeObject(o);
This works in the scenario I used to reproduce.
Steps to reproduce this issue
I'm currently trying to come up with a unit test that reproduces without Spring, I will update this section when done.

#5
Comment posted by
 lolo4j
Jun 11, 07:27
Fixed in: