You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Michael Baessler <mb...@michael-baessler.de> on 2008/01/25 13:06:58 UTC

covert ArrayFS to StringArray

Hi,

is it correct that the code fragment below throws and NPE if one of the 
array elements is null and the array is converted to a StringArray?

     ArrayFS fsArrayFS = cas.createArrayFS(3);
      fsArrayFS.set(0, cas.getDocumentAnnotation());
      fsArrayFS.set(1, cas.getDocumentAnnotation());
      fsArrayFS.toStringArray(); // throws NPE

When doing the same for StringArrayFS the last element in the resultant 
StringArray is null. The seems to me the desired behavior.

-- Michael


Re: covert ArrayFS to StringArray

Posted by Thilo Goetz <tw...@gmx.de>.
Right, that's a bug.  I'll open an issue.

--Thilo

Michael Baessler wrote:
> Hi,
> 
> is it correct that the code fragment below throws and NPE if one of the 
> array elements is null and the array is converted to a StringArray?
> 
>     ArrayFS fsArrayFS = cas.createArrayFS(3);
>      fsArrayFS.set(0, cas.getDocumentAnnotation());
>      fsArrayFS.set(1, cas.getDocumentAnnotation());
>      fsArrayFS.toStringArray(); // throws NPE
> 
> When doing the same for StringArrayFS the last element in the resultant 
> StringArray is null. The seems to me the desired behavior.
> 
> -- Michael