scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

FieldCache is not thread safe

Open ctrueden opened this issue 7 years ago • 0 comments

From Gitter:

I'm getting a mix of the following errors if I use a separate instance of OpService in each worker thread:

java.lang.IllegalArgumentException: Invalid service: net.imagej.ops.DefaultOpService
    at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:281)
    at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:232)
    at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:195)
    at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:167)
    ...
Caused by: java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
    at java.util.ArrayList$Itr.next(ArrayList.java:851)
    at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:318)
    ...

The offending line is:

List<Field> fields = fieldCache.getList(c, annotationClass);

I want to remove this crazy fieldCache logic, but only if it does not destroy performance.

ctrueden avatar Dec 15 '18 23:12 ctrueden