imsweb / mph

Java implementation of the Multiple Primary and Histology Coding Rules.
Other
4 stars 2 forks source link

Concurrent Modification Exception #126

Closed bekeles closed 1 year ago

bekeles commented 1 year ago

The linkage session failed for the following reason(s): java.util.ConcurrentModificationException at java.base/java.util.HashMap.computeIfAbsent(Unknown Source) at com.imsweb.mph.DefaultHematoDataProvider.getTransformTo(DefaultHematoDataProvider.java:111) at com.imsweb.mph.MphUtils.confirmTransformTo(MphUtils.java:361) at com.imsweb.mph.MphUtils.isChronicToAcuteTransformation(MphUtils.java:352) at com.imsweb.mph.MphUtils.isTransformation(MphUtils.java:347) at com.imsweb.mph.RuleExecutionContext.isTransformation(RuleExecutionContext.java:19) at com.imsweb.mph.mpgroups.Mp2010HematopoieticGroup$8.apply(Mp2010HematopoieticGroup.java:247) at com.imsweb.mph.MphUtils.computePrimaries(MphUtils.java:261) at com.imsweb.matchpro.library.linkage.matching.comparator.comparators.SolidTumorMPHComparator.compareWithAnnotation(SolidTumorMPHComparator.java:69) at com.imsweb.matchpro.library.linkage.consumer.LinkageComparison.compare(LinkageComparison.java:160) at com.imsweb.matchpro.library.linkage.consumer.LinkageComparison.(LinkageComparison.java:55) at com.imsweb.matchpro.library.linkage.consumer.LinkageConsumer.createLinkageResult(LinkageConsumer.java:256) at com.imsweb.matchpro.library.linkage.consumer.LinkageConsumer.consume(LinkageConsumer.java:168) at com.imsweb.matchpro.library.linkage.consumer.LinkageConsumer.run(LinkageConsumer.java:337) at java.base/java.lang.Thread.run(Unknown Source)

bekeles commented 1 year ago

@depryf I think the exception happened because computeIfAbsent method of HashMap updates the map. I think using getOrDefault will fix this.

depryf commented 1 year ago

I agree with that. Those maps should definitively not be modified in any way after initialization. Please make sure there are no other instances trying to modify those maps. Thanks.

bekeles commented 1 year ago

Yes there are 3 places and I fixed them all.

depryf commented 1 year ago

Great. Thanks for looking into this so quickly.

Go ahead and make a PR, and I will review it, merge and release.

depryf commented 1 year ago

Fix will be released in version 1.32.