Calling jcas.getType for a type that is not defined in the descriptor leaves 
the JCAS in an inconsitent state
-------------------------------------------------------------------------------------------------------------

                 Key: UIMA-738
                 URL: https://issues.apache.org/jira/browse/UIMA-738
             Project: UIMA
          Issue Type: Bug
          Components: Core Java Framework
    Affects Versions: 2.2.1
            Reporter: Adam Lally
            Assignee: Adam Lally
             Fix For: 2.3


The following code illustrates the problem:

  public void testUndefinedType() throws Exception {
    //create jcas with no type system
    JCas jcas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), 
null, null).getJCas();
    jcas.setDocumentText("This is a test.");
    try {
      //this should throw an exception
      jcas.getType(Sentence.type);
      fail(); 
    } catch(CASRuntimeException e) {
    }
    //check that this does not leave JCAS in an inconsistent state
    Iterator iter = jcas.getAnnotationIndex().iterator();
    assertTrue(iter.hasNext());
    Annotation annot = (Annotation)iter.next();
  }

Running this gives a ClassCastException trying to cast the result of 
iter.next() to an Annotation


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to