thread safety issue with sample flow controller AdvancedFixedFlowController
---------------------------------------------------------------------------

                 Key: UIMA-1153
                 URL: https://issues.apache.org/jira/browse/UIMA-1153
             Project: UIMA
          Issue Type: Bug
          Components: Async Scaleout, Examples
    Affects Versions: 2.2.2
            Reporter: Marshall Schor
            Priority: Minor


The AdvancedFixedFlowController implements its Flow Object class as an inner 
class of its Flow Controller class.

In UIMA-AS, it is possible that more than one Flow Object can be accessing the 
Flow Controller fields on different threads, and (for Cas Multipliers) it is 
possible for an individual Flow Object to be called on multiple threads at the 
same time (via the method (via the newCasProduced method).  

In the example, the newCasProduced method is marked *synchronized*, so I think 
the same Flow Object will not be running multiple threads at the same time, 
because the other methods to this are all calls done on 1 thread on behalf of 
the main CAS associated with this Flow Object.

However, multiple flow objects running on different threads could have their 
newCasProduced method called.  In this case, the references in that method to 
common mutable fields in the shared Flow Controller object are not 
synchronized.  This code should be fixed so that those references are 
synchronized on the same monitor used to synchronize other field access in the 
Flow Controller.  UIMA-1149 I hope will use the class instance of the flow 
controller for this purpose, and, assuming that it does, this code should 
explicitly synchronize on that same object, for references to mutable fields in 
that class.  There is one field, mSequence, which is in the associated Flow 
Controller class, which is mutable (in theory).  References to this field 
should be synchronized with the same monitor used by the flow controller class 
when manipulating it.

The other field references in the flow object should be checked, and 
synchronized if they refer to mutable Flow Controller fields.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to