You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2016/01/05 23:10:14 UTC

svn commit: r1723187 - in /uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl: XCASDeserializer.java XmiCasDeserializer.java

Author: schor
Date: Tue Jan  5 22:10:14 2016
New Revision: 1723187

URL: http://svn.apache.org/viewvc?rev=1723187&view=rev
Log:
[UIMA-4722] fix updateDocumentAnnotation to remove and addback in the right index. 

Modified:
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java?rev=1723187&r1=1723186&r2=1723187&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASDeserializer.java Tue Jan  5 22:10:14 2016
@@ -778,16 +778,7 @@ public class XCASDeserializer {
       }
 
       for (CAS view : views) {
-        AutoCloseable ac = view.protectIndexes();
-        try {
-          ((CASImpl)view).updateDocumentAnnotation();
-        } finally {
-          try {
-            ac.close();
-          } catch (Exception e) {
-            assert(false);
-          }
-        }
+        ((CASImpl)view).updateDocumentAnnotation();
       }
 //      for (int i = 0; i < views.size(); i++) {       
 //        ((CASImpl) views.get(i)).updateDocumentAnnotation();

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java?rev=1723187&r1=1723186&r2=1723187&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java Tue Jan  5 22:10:14 2016
@@ -755,52 +755,56 @@ public class XmiCasDeserializer {
       
       this.featsSeen = null;
       
-      // before looping over all features for this FS, remove this FS if in any index.
+      // before looping over all features for this FS, remove this FS if it's not new and if in any index.
       // we do this once, before the feature setting loop, because that loop may set a sofa Ref which is 
       // invalid (to be fixed up later). But the removal code needs a valid sofa ref.
-      if (!isNewFs) {   
-        casBeingFilled.removeFromCorruptableIndexAnyViewSetCache(fsAddr, casBeingFilled.getAddbackSingle());
-        // else clause not needed because caller does ll_createFS which sets this anyways
-//      } else {  
-//        // need this to prevent using sofa ref before it's set
-//        casBeingFilled.setCacheNotInIndex(fsAddr);  // new FSs are not indexed (yet)
-      }
-      // loop over all features for this FS
-      for (int i = 0; i < attrs.getLength(); i++) {
-        attrName = attrs.getQName(i);
-        attrValue = attrs.getValue(i);
-        if (attrName.equals(ID_ATTR_NAME)) {
-          try {
-            id = Integer.parseInt(attrValue);
-//            newFS = this.isNewFS(id);  // we already specifically got this attribute
-            if (sofaTypeCode != typeCode && !isNewFs) {
-              this.featsSeen = new IntVector(attrs.getLength());
-            } else {
-              this.featsSeen = null;
+      try {
+        if (!isNewFs) {   
+        
+          casBeingFilled.removeFromCorruptableIndexAnyViewSetCache(fsAddr, casBeingFilled.getAddbackSingle());
+          // else clause not needed because caller does ll_createFS which sets this anyways
+  //      } else {  
+  //        // need this to prevent using sofa ref before it's set
+  //        casBeingFilled.setCacheNotInIndex(fsAddr);  // new FSs are not indexed (yet)
+        }
+        // loop over all features for this FS
+        for (int i = 0; i < attrs.getLength(); i++) {
+          attrName = attrs.getQName(i);
+          attrValue = attrs.getValue(i);
+          if (attrName.equals(ID_ATTR_NAME)) {
+            try {
+              id = Integer.parseInt(attrValue);
+  //            newFS = this.isNewFS(id);  // we already specifically got this attribute
+              if (sofaTypeCode != typeCode && !isNewFs) {
+                this.featsSeen = new IntVector(attrs.getLength());
+              } else {
+                this.featsSeen = null;
+              }
+            } catch (NumberFormatException e) {
+              throw createException(XCASParsingException.ILLEGAL_ID, attrValue);
             }
-          } catch (NumberFormatException e) {
-            throw createException(XCASParsingException.ILLEGAL_ID, attrValue);
-          }
-        } else {
-          if (sofaTypeCode == typeCode && attrName.equals(CAS.FEATURE_BASE_NAME_SOFAID)) {
-            if (attrValue.equals("_DefaultTextSofaName")) {
-              // First change old default Sofa name into the new one
-              attrValue = CAS.NAME_DEFAULT_SOFA;
+          } else {
+            if (sofaTypeCode == typeCode && attrName.equals(CAS.FEATURE_BASE_NAME_SOFAID)) {
+              if (attrValue.equals("_DefaultTextSofaName")) {
+                // First change old default Sofa name into the new one
+                attrValue = CAS.NAME_DEFAULT_SOFA;
+              }
+            } else if (sofaTypeCode == typeCode && attrName.equals(CAS.FEATURE_BASE_NAME_SOFANUM)) {
+              attrValue = Integer.toString(thisSofaNum);
+            }
+            int featCode = handleFeature(type, fsAddr, attrName, attrValue, isNewFs);
+            //if processing delta cas preexisting FS, keep track of features that have
+            //been deserialized.
+            if (this.featsSeen != null && !isNewFs && featCode != -1) {
+              this.featsSeen.add(featCode); 
             }
-          } else if (sofaTypeCode == typeCode && attrName.equals(CAS.FEATURE_BASE_NAME_SOFANUM)) {
-            attrValue = Integer.toString(thisSofaNum);
-          }
-          int featCode = handleFeature(type, fsAddr, attrName, attrValue, isNewFs);
-          //if processing delta cas preexisting FS, keep track of features that have
-          //been deserialized.
-          if (this.featsSeen != null && !isNewFs && featCode != -1) {
-            this.featsSeen.add(featCode); 
           }
+        }  // end of all features loop
+        
+      } finally {
+        if (!isNewFs) {
+          casBeingFilled.addbackSingle(fsAddr);
         }
-      }  // end of all features loop
-      
-      if (!isNewFs) {
-        casBeingFilled.addbackSingle(fsAddr);
       }
       
       if (sofaTypeCode == typeCode && isNewFs) {
@@ -1505,16 +1509,7 @@ public class XmiCasDeserializer {
 
       
       for (CAS view : views) {
-        AutoCloseable ac = view.protectIndexes();
-        try {
-          ((CASImpl) view).updateDocumentAnnotation();
-        } finally {
-          try {
-            ac.close();
-          } catch (Exception e1) {
-            assert(false);
-          }
-        }
+        ((CASImpl) view).updateDocumentAnnotation();
       }