net.sf.JRecord.Details.LayoutDetail is not thread safe
Read Cobol data files in Java
Status: Beta
Brought to you by:
bruce_a_martin
Hi Bruce,
I have slurper which calls getFieldNameMap method in net.sf.JRecord.Details.LayoutDetail class and whenever i have parallel threads running i am getting ConcurrentModificationException
java.util.ConcurrentModificationException: null
at net.sf.JRecord.Details.LayoutDetail.getFieldNameMap(LayoutDetail.java:1048) ~[ao-jrecord-0.90.0.RC7.jar:na]
at net.sf.JRecord.Details.LayoutDetail$getFieldNameMap$0.call(Unknown Source) ~[na:na]
Anonymous
I will add a synronize to relavent part
Thanks, Can you use Concurrent HashMap instead of making it synchronized ?
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html
Last edit: Bhargav 2020-01-31
I am adding syncronized around the Map creation code. For Cobol the Map is created once when needed and never updated. This code needs to be syncronized to handle duplicate field names in Cobol. The getFieldNameMap returns a copy of the internal map.
I do not see the need for a Concurrent HashMap in JRecord itself. I can look adding an option to update a map if you need / want another type of map..
I plan to update GitHub with my changes over the weekend
Thanks Bruce...
Github has been updated: https://github.com/bmTas/JRecord
Thank you