uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Kottmann <kottm...@gmail.com>
Subject NPE from ArrayFS.get method
Date Wed, 16 Jan 2013 11:14:02 GMT
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?

Jörn

Mime
View raw message