Menu

#30 net.sf.JRecord.Details.LayoutDetail is not thread safe

v1.0_(example)
open
None
1
2020-06-09
2020-01-30
Bhargav
No

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] 

Discussion

  • Bruce Martin

    Bruce Martin - 2020-01-30

    I will add a synronize to relavent part

     
  • Bhargav

    Bhargav - 2020-01-31

    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
  • Bruce Martin

    Bruce Martin - 2020-02-01

    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

     
  • Anonymous

    Anonymous - 2020-02-01

    Thanks Bruce...

     
  • Bruce Martin

    Bruce Martin - 2020-02-02

    Github has been updated: https://github.com/bmTas/JRecord

     
  • Bhargav

    Bhargav - 2020-02-03

    Thank you

     
  • Bruce Martin

    Bruce Martin - 2020-06-09
    • assigned_to: Bruce Martin
     

Anonymous
Anonymous

Add attachments
Cancel