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/09/01 17:10:40 UTC

svn commit: r1758814 - in /uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima: analysis_engine/asb/impl/ analysis_engine/impl/ cas/impl/

Author: schor
Date: Thu Sep  1 17:10:39 2016
New Revision: 1758814

URL: http://svn.apache.org/viewvc?rev=1758814&view=rev
Log:
[UIMA-5097] make resets to componentInfo more reliable.

Modified:
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowContainer.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowControllerContainer.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/PrimitiveAnalysisEngine_impl.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowContainer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowContainer.java?rev=1758814&r1=1758813&r2=1758814&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowContainer.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowContainer.java Thu Sep  1 17:10:39 2016
@@ -55,12 +55,12 @@ public class FlowContainer {
     mCAS = (CASImpl)aCAS;
   }
 
-  public FlowContainer newCasProduced(CAS newCAS, String producedBy)
+  public FlowContainer newCasProduced(final CAS newCAS, String producedBy)
           throws AnalysisEngineProcessException {
     mTimer.startIt();
     CAS view = null;
     try {
-      view = Util.getStartingView(
+      view = Util.getStartingView(   
           newCAS, 
           mSofaAware, 
           mFlowControllerContainer.getUimaContextAdmin().getComponentInfo());
@@ -81,9 +81,9 @@ public class FlowContainer {
     } catch (CASException e) {
       throw new AnalysisEngineProcessException(e);
     } finally {
+      newCAS.setCurrentComponentInfo(null);
       if (null != view) {
         ((CASImpl)view).restoreClassLoaderUnlockCas();
-        view.setCurrentComponentInfo(null);
       }
       mTimer.stopIt();
       getMBean().reportAnalysisTime(mTimer.getDuration());

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowControllerContainer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowControllerContainer.java?rev=1758814&r1=1758813&r2=1758814&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowControllerContainer.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/asb/impl/FlowControllerContainer.java Thu Sep  1 17:10:39 2016
@@ -212,12 +212,12 @@ public class FlowControllerContainer ext
    * @throws AnalysisEngineProcessException
    *           if the FlowController failed
    */
-  public FlowContainer computeFlow(CAS aCAS) throws AnalysisEngineProcessException {
+  public FlowContainer computeFlow(final CAS aCAS) throws AnalysisEngineProcessException {
     mTimer.startIt();
     CAS view = null;
     try {
-      view = Util.getStartingView(aCAS, mSofaAware, getUimaContextAdmin().getComponentInfo());
-
+      // throws if _InitialView is mapped to non-existent sofa https://issues.apache.org/jira/browse/UIMA-5097
+      view = Util.getStartingView(aCAS, mSofaAware, getUimaContextAdmin().getComponentInfo());     
       // now get the right interface(e.g. CAS or JCAS)
       UimaContextHolder.setContext(getFlowControllerContext());  // for use by POJOs
       Class<? extends AbstractCas> requiredInterface = mFlowController.getRequiredCasInterface();
@@ -234,9 +234,9 @@ public class FlowControllerContainer ext
     } catch (CASException e) {
       throw new AnalysisEngineProcessException(e);
     } finally {
+      aCAS.setCurrentComponentInfo(null); // https://issues.apache.org/jira/browse/UIMA-5097
       if (view != null) {
-        ((CASImpl)view).restoreClassLoaderUnlockCas();
-        view.setCurrentComponentInfo(null);
+        ((CASImpl)view).restoreClassLoaderUnlockCas();      
       }
       mTimer.stopIt();
       getMBean().reportAnalysisTime(mTimer.getDuration());

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/PrimitiveAnalysisEngine_impl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/PrimitiveAnalysisEngine_impl.java?rev=1758814&r1=1758813&r2=1758814&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/PrimitiveAnalysisEngine_impl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/analysis_engine/impl/PrimitiveAnalysisEngine_impl.java Thu Sep  1 17:10:39 2016
@@ -350,7 +350,7 @@ public class PrimitiveAnalysisEngine_imp
    *          CAS to be processed by annotator
    * @throws AnalysisEngineProcessException -         
    */
-  protected void callAnalysisComponentProcess(CAS aCAS) throws AnalysisEngineProcessException {
+  protected void callAnalysisComponentProcess(final CAS aCAS) throws AnalysisEngineProcessException {
     // logging and instrumentation
     String resourceName = getMetaData().getName();
     Logger logger = getLogger();
@@ -363,6 +363,7 @@ public class PrimitiveAnalysisEngine_imp
 
         // Get the right view of the CAS. Sofa-aware components get the base CAS.
         // Sofa-unaware components get whatever is mapped to the _InitialView.
+        //    note: if initial view is mapped, and the mapped view doesn't exist, throws an exception.
         view = Util.getStartingView(aCAS, mSofaAware, getUimaContextAdmin().getComponentInfo());
         // now get the right interface(e.g. CAS or JCAS)
         // must precede the switchClassLoader call below UIMA-2211
@@ -403,7 +404,6 @@ public class PrimitiveAnalysisEngine_imp
       } catch (Exception e) {
         // catching Throwable to catch out-of-memory errors too, which are not Exceptions
         if (null != view) {
-          view.setCurrentComponentInfo(null);
           ((CASImpl)view).restoreClassLoaderUnlockCas();
         }
         if (e instanceof AnalysisEngineProcessException) {
@@ -414,11 +414,11 @@ public class PrimitiveAnalysisEngine_imp
         }
       } catch (Error e) {  // out of memory error, for instance
         if (null != view) {
-          view.setCurrentComponentInfo(null);
           ((CASImpl)view).restoreClassLoaderUnlockCas();
         }
         throw e;
       } finally {
+        aCAS.setCurrentComponentInfo(null); // https://issues.apache.org/jira/browse/UIMA-5097
         UimaContextHolder.clearContext();
       }
 
@@ -537,7 +537,7 @@ public class PrimitiveAnalysisEngine_imp
       } else {
         casToReturn = (CAS) absCas;
       }
-      casToReturn = casToReturn.getView(CAS.NAME_DEFAULT_SOFA);
+      casToReturn = casToReturn.getView(CAS.NAME_DEFAULT_SOFA); 
 
       // clear the CAS's component info, since it is no longer
       // being processed by this AnalysisComponent

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1758814&r1=1758813&r2=1758814&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Thu Sep  1 17:10:39 2016
@@ -1144,8 +1144,11 @@ public class CASImpl extends AbstractCas
     this.svd.fssTobeAddedback.clear();
     this.svd.fssTobeAddedback.trimToSize();
     
-    svd.traceFSid = 0;
-    if (traceFSs) svd.traceFScreationSb.setLength(0);
+    this.svd.traceFSid = 0;
+    if (traceFSs) { 
+      this.svd.traceFScreationSb.setLength(0);
+    }
+    this.svd.componentInfo = null; // https://issues.apache.org/jira/browse/UIMA-5097
   }
 
   /**