Skip to content

FieldCache is not thread safe #347

Open
@ctrueden

Description

@ctrueden

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions