Author: schor
Date: Wed Aug 17 17:16:56 2016
New Revision: 1756659

URL: http://svn.apache.org/viewvc?rev=1756659&view=rev
Log:
[UIMA-5056] added throwing exception if nested switch

Modified:
    
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
    
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
    
uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties

Modified: 
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java?rev=1756659&r1=1756658&r2=1756659&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
 Wed Aug 17 17:16:56 2016
@@ -219,6 +219,9 @@ public class CASRuntimeException extends
   /** Lenient deserialization not support for input of type {0}. */
   public static final String LENIENT_NOT_SUPPORTED = "LENIENT_NOT_SUPPORTED";
   
+  /** Multiply nested classloaders not supported.  Original base loader: {0}, 
current nested loader: {1}, trying to switch to loader: {2}.*/
+  public static final String SWITCH_CLASS_LOADER_NESTED = 
"SWITCH_CLASS_LOADER_NESTED";
+  
        public CASRuntimeException() {
                super();
        }

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=1756659&r1=1756658&r2=1756659&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 
Wed Aug 17 17:16:56 2016
@@ -4252,6 +4252,11 @@ public class CASImpl extends AbstractCas
       return;
     }
     if (newClassLoader != this.svd.jcasClassLoader) {
+      if (this.svd.jcasClassLoader != this.svd.previousJCasClassLoader) {
+        /** Multiply nested classloaders not supported.  Original base loader: 
{0}, current nested loader: {1}, trying to switch to loader: {2}.*/
+        throw new 
CASRuntimeException(CASRuntimeException.SWITCH_CLASS_LOADER_NESTED, 
+                                      new Object[] 
{this.svd.previousJCasClassLoader, this.svd.jcasClassLoader, newClassLoader});
+      }
       // System.out.println("Switching to new class loader");
       this.svd.jcasClassLoader = newClassLoader;
       if (null != this.jcas) {

Modified: 
uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties?rev=1756659&r1=1756658&r2=1756659&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
 (original)
+++ 
uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
 Wed Aug 17 17:16:56 2016
@@ -572,4 +572,5 @@ DESERIALIZING_BINARY_INVALID_HEADER = Wh
 DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED = Using the reinit method to 
deserialize a binary CAS serialized with compressed serialization not supported 
for this case.
 DEREF_FS_OTHER_CAS = Dereferencing a FeatureStructure of a CAS in a different 
CAS''s context. This can happen if you try to set a feature structure reference 
to a value of a feature structure belonging to an entirely different CAS. FS = 
"{0}", CAS = "{1}".
 ILLEGAL_FEAT_SET = While a FeatureStructure was in the index, an illegal 
attempt was made to modify Feature "{0}" which is used as a key in one or more 
indices; the Feature Structure being modified was "{1}".
-LENIENT_NOT_SUPPORTED = Lenient deserialization not support for input of type 
{0}.
\ No newline at end of file
+LENIENT_NOT_SUPPORTED = Lenient deserialization not support for input of type 
{0}.
+SWITCH_CLASS_LOADER_NESTED = Multiply nested classloaders not supported.  
Original base loader: {0}, current nested loader: {1}, trying to switch to 
loader: {2}.
\ No newline at end of file


Reply via email to