Am 16.01.2013 um 09:14 schrieb Jörn Kottmann <[email protected]>:

> Hi all,
> 
> I am getting a NullPointerException while calling ArrayFS.get().
> 
> Here is the exception:
> java.lang.NullPointerException
>    at org.apache.uima.cas.impl.CASImpl.ll_getFSForRef(CASImpl.java:3117)
>    at org.apache.uima.cas.impl.CASImpl.createFS(CASImpl.java:1773)
>    at org.apache.uima.cas.impl.ArrayFSImpl.get(ArrayFSImpl.java:50)
> 
> 
> The code causing this exception looks like this:
> ArrayFS mentionArray = (ArrayFS) 
> entityAnnotation.getFeatureValue(mentionsFeature);
> 
> for (int i = 0; i < mentionArray.size(); i++) {
>  AnnotationFS mentionAnn = (AnnotationFS) mentionArray.get(i);
>  ...
> }
> 
> The actual bug here is in the AE which is creating the array and filling
> it with Feature Structures a few nodes before in the pipeline.
> In that AE the scope of a variable was wrong (instance instead of local)
> and it accidentally wrote FSes from another CAS passed previously to the
> process method into the ArrayFS.
> 
> I am wondering if it would be worth making mistakes like this fail fast,
> with other words it should throw an exception while putting the dangling FS
> into the array.
> 
> Any opinions?


Throwing an exception when inserting dangling FSes sounds like a good idea.
To check if a CAS address is still resolving,  a lookup can be made via 
the CAS address directly, thus, the time effort shouldn't be too high. 
Maybe do the same check when settings a feature to an FS value?

However, even a resolving CAS address doesn't mean that the FS
is still valid. The CAS might meanwhile have been reset and the address
might just again have been assigned. Maintaining a serial number in the
CAS and in every FS sounds like overkill. 

So given a check for an resolving CAS address doesn't catch 100% of the
problem cases and costs extra time, is it worth to this check at all?

Any better ideas to check for dangling references?

-- Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab (UKP-TUD) 
FB 20 Computer Science Department      
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
[email protected] 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
-------------------------------------------------------------------

Reply via email to