Avi-Levi / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Support concurrent access of Kryo.register #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When Kryo is used in a multi-threaded environment external synchronization is 
required to ensure that the internally used HashMap classToRegisteredClass (and 
probably the IntHashMap idToRegisteredClass) cannot be broken which might cause 
infinite loops.

The suggested patch now synchronizes write access of classToRegisteredClass on 
exactly this object. From my understanding this is enough to ensure that the 
HashMap internal linked lists cannot be broken. As read access is not 
synchronized it might happen that some thread gets an "invalid" object from the 
map that is replaced by a second thread, but IMHO this isn't an issue as 
correct functionality/behavior is not affected by this.

As the synchronized block on classToRegisteredClass also included the 
idToRegisteredClass.put, I think this potential concurrency issue is also 
solved.

Is this patch acceptable? Can you apply it as soon as possible and make a new 
release? This would save the world for me right now :-)

Original issue reported on code.google.com by martin.grotzke on 8 Sep 2010 at 1:05

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Fixed in r123.

Original comment by nathan.s...@gmail.com on 8 Sep 2010 at 8:53

GoogleCodeExporter commented 9 years ago

Original comment by nathan.s...@gmail.com on 10 Oct 2010 at 2:48