You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Richard Eckart de Castilho (JIRA)" <de...@uima.apache.org> on 2017/09/22 09:43:00 UTC
[jira] [Comment Edited] (UIMA-5586) uv3: DocumentAnnotation
subclasses not handled as in UIMAv2 during deserialization
[ https://issues.apache.org/jira/browse/UIMA-5586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16176191#comment-16176191 ]
Richard Eckart de Castilho edited comment on UIMA-5586 at 9/22/17 9:42 AM:
---------------------------------------------------------------------------
Possibly related to this issue is another observation. When deserializing some binary CAS formats, there is a NPE in certain cases. Here is an example that might serve for reproduction:
{noformat}
@Test
public void test6LenientPlainUima() throws Exception
{
CAS source = JCasFactory.createJCas().getCas();
CAS target = JCasFactory.createJCas().getCas();
new DocumentMetaData(source.getJCas(), 0, 0).addToIndexes();
@SuppressWarnings("resource")
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CasIOUtils.save(source, bos, COMPRESSED_FILTERED);
bos.close();
CasIOUtils.load(new ByteArrayInputStream(bos.toByteArray()), target);
}
{noformat}
The NPE only seems to be thrown when the `DocumentMetaData` is added via JCas:
{noformat}
java.lang.NullPointerException
at org.apache.uima.cas.impl.CASImpl.getView(CASImpl.java:2224)
at org.apache.uima.cas.impl.BinaryCasSerDes6.deserializeAfterVersion(BinaryCasSerDes6.java:1892)
at org.apache.uima.cas.impl.BinaryCasSerDes.reinit(BinaryCasSerDes.java:595)
at org.apache.uima.util.CasIOUtils.load(CasIOUtils.java:382)
at org.apache.uima.util.CasIOUtils.load(CasIOUtils.java:313)
at org.apache.uima.util.CasIOUtils.load(CasIOUtils.java:237)
...
{noformat}
I have set up a similar test using only the plain CAS API which seems to work fine:
{noformat}
@Test
public void test6LenientPlainUima2() throws Exception
{
TypeSystemDescription tsd = new TypeSystemDescription_impl();
TypeDescription td = tsd.addType("DocumentMetaData", "", CAS.TYPE_NAME_DOCUMENT_ANNOTATION);
td.addFeature("feat", "", CAS.TYPE_NAME_STRING);
CAS source = CasCreationUtils.createCas(tsd, null, null, null);
CAS target = CasCreationUtils.createCas(tsd, null, null, null);
AnnotationFS dmd = source
.createAnnotation(source.getTypeSystem().getType("DocumentMetaData"), 0, 0);
source.addFsToIndexes(dmd);
assertEquals("DocumentMetaData", source.getDocumentAnnotation().getType().getName());
@SuppressWarnings("resource")
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CasIOUtils.save(source, bos, COMPRESSED_FILTERED);
bos.close();
CasIOUtils.load(new ByteArrayInputStream(bos.toByteArray()), target);
}
{noformat}
was (Author: rec):
Possibly related to this issue is another observation. When deserializing some binary CAS formats, there is a NPE in certain cases. Here is an example that might serve for reproduction:
{noformat}
@Test
public void test6LenientPlainUima() throws Exception
{
CAS source = JCasFactory.createJCas().getCas();
CAS target = JCasFactory.createJCas().getCas();
new DocumentMetaData(source.getJCas(), 0, 0).addToIndexes();
@SuppressWarnings("resource")
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CasIOUtils.save(source, bos, COMPRESSED_FILTERED);
bos.close();
CasIOUtils.load(new ByteArrayInputStream(bos.toByteArray()), target);
}
{noformat}
The NPE only seems to be thrown when the `DocumentMetaData` is added via JCas.
I have set up a similar test using only the plain CAS API which seems to work fine:
{noformat}
@Test
public void test6LenientPlainUima2() throws Exception
{
TypeSystemDescription tsd = new TypeSystemDescription_impl();
TypeDescription td = tsd.addType("DocumentMetaData", "", CAS.TYPE_NAME_DOCUMENT_ANNOTATION);
td.addFeature("feat", "", CAS.TYPE_NAME_STRING);
CAS source = CasCreationUtils.createCas(tsd, null, null, null);
CAS target = CasCreationUtils.createCas(tsd, null, null, null);
AnnotationFS dmd = source
.createAnnotation(source.getTypeSystem().getType("DocumentMetaData"), 0, 0);
source.addFsToIndexes(dmd);
assertEquals("DocumentMetaData", source.getDocumentAnnotation().getType().getName());
@SuppressWarnings("resource")
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CasIOUtils.save(source, bos, COMPRESSED_FILTERED);
bos.close();
CasIOUtils.load(new ByteArrayInputStream(bos.toByteArray()), target);
}
{noformat}
> uv3: DocumentAnnotation subclasses not handled as in UIMAv2 during deserialization
> ----------------------------------------------------------------------------------
>
> Key: UIMA-5586
> URL: https://issues.apache.org/jira/browse/UIMA-5586
> Project: UIMA
> Issue Type: Bug
> Components: Core Java Framework
> Affects Versions: 3.0.0SDK-beta
> Reporter: Richard Eckart de Castilho
>
> Consider the case that you have custom subclass of the uima `DocumentAnnotation`, let's call it `DocumentMetaData`. Next, we have an XMI file which contains an annotation of the `DocumentMetaData` type.
> When loading such an XMI file in UIMAv2, the CAS ends up with a single `DocumentMetaData` annotation which is accessible via `cas.getDocumentAnnotation()`.
> When loading the same file with UIMAv3, the CAS ends up with both, a `DocumentAnnotation` and a `DocumentMetaData` annotation and `cas.getDocumentAnnotation()` returns the former.
> The same appears to happen when deserializing a CAS from various binary formats.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)