Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-5588

uv3: NPE during deserialization under certain circumstances

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0SDK-beta
    • 3.0.0SDK
    • Core Java Framework
    • None

    Description

      This was previously thought to be covered by UIMA-5586 - however, the problem remains after the order of the deserialization had been fixed in UIMA-5586.

      When deserializing some binary CAS formats, there is a NPE in certain cases. Here is an example that might serve for reproduction:

          @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);
          }
      

      Mind this is a minimal code for reproduction. The same happens when deserializing within the context of an initialized AnalysisEngine.

      The NPE only seems to be thrown when the `DocumentMetaData` is added via JCas:

      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)
              ...
      

      I have set up a similar test using only the plain CAS API which seems to work fine:

          @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);
          }
      

      Attachments

        Activity

          People

            schor Marshall Schor
            rec Richard Eckart de Castilho
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: