[ 
https://issues.apache.org/jira/browse/UIMA-3655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13915003#comment-13915003
 ] 

Marshall Schor commented on UIMA-3655:
--------------------------------------

Some issues:  It may break backwards compatibility to switch to using the base 
cas, because embedders will be expecting to use the "_initialView" when using 
the CasPool public methods getFreeInstances() and getAllInstances().

Sofa Mapping is a concept associated with aggregates.  Mappings are possibly 
needed for delegates which are sofa-unaware; each delegate might have a 
different mapping.  There is code to update a CAS while a delegate (primitive) 
is running, to specify the sofa mapping - this is done by setting the mapping 
prior to running the delegate, and resetting it back to null (preferably in a 
try / finally).  You can see this being done in the CPM' ArtifactProducer code 
- line 474 sets it into the CAS, and the finally block at 534 resets it.  There 
are several "holes" in the other spots that reset this, because they're not 
done in finally blocks.

When a CasPool is created, it is prior to any of the pipeline being run, so no 
sofa mappings are present in the CAS, and the CASes that are put into the pool 
(by the fillPool method) are instances of the "_initialView" CAS view.

The error most likely happened when some exception occurred after the sofa 
mapping was put into the CAS's currentComponentInfo spot, and not reset via a 
"finally" block.  Even if the sofa was present, the releaseCas method would 
have failed, because it would have successfully found the mapped view, which 
would not compare == to any of the set of CASes the casPool knew about (and it 
checks, and would throw an error).

The quick fix is to set the currentComponentInfo in the CAS being returned to 
null, before getting the initial view.  The additional cleanup is to track down 
and find all the spots where this is not being done properly in a try/finally 
block, and fix those, too.

> CasPool incorrectly stores references to the InitialView of each CAS
> --------------------------------------------------------------------
>
>                 Key: UIMA-3655
>                 URL: https://issues.apache.org/jira/browse/UIMA-3655
>             Project: UIMA
>          Issue Type: Bug
>          Components: Core Java Framework
>            Reporter: Eddie Epstein
>            Assignee: Marshall Schor
>
> For cas pools, getCas returns a handle to the InitialView of an empty CAS,
> and stores this handle to match in releaseCas. This breaks for services that 
> employ sofamapping. The empty CAS is filled from a serialized CAS sent to the 
> service. It is possible that a CAS received may not contain the view, 
> CAS.NAME_DEFAULT_SOFA, specified by sofamapping.
> Then, when the service tries to return the CAS to the pool, releaseCas blows 
> up at the first line,
> CAS cas = aCas.getView(CAS.NAME_DEFAULT_SOFA);
> so the CAS is not returned to the pool ==> CAS leak.
> The cas pool should be storing references to the base CAS, which is 
> independent of views.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to