Anonymous avatar Anonymous committed 9142b98

Fixes OGNL-106. Wasn't checking for null in ASTMethod.

Also refactored exception catching logic so that more exceptions aren't needlessly added on to the exception stack when catching Throwables.

Comments (0)

Files changed (24)

   </component>
   <component name="ChangeListManager">
     <list default="true" name="Default" comment="">
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/ognl/TestOgnlRuntime.java" afterPath="$PROJECT_DIR$/src/test/java/ognl/TestOgnlRuntime.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTOr.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTOr.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/OgnlOps.java" afterPath="$PROJECT_DIR$/src/java/ognl/OgnlOps.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java" afterPath="$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/NumericExpression.java" afterPath="$PROJECT_DIR$/src/java/ognl/NumericExpression.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTStaticMethod.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTStaticMethod.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ListPropertyAccessor.java" afterPath="$PROJECT_DIR$/src/java/ognl/ListPropertyAccessor.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTNotIn.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTNotIn.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTAdd.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTAdd.java" />
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/OGNL.iws" afterPath="$PROJECT_DIR$/OGNL.iws" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/OGNL.ipr" afterPath="$PROJECT_DIR$/OGNL.ipr" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java" afterPath="$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/test/java/org/ognl/test/enhance/TestExpressionCompiler.java" afterPath="$PROJECT_DIR$/src/test/java/org/ognl/test/enhance/TestExpressionCompiler.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTMethod.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTMethod.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTIn.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTIn.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTNot.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTNot.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTTest.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTTest.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ComparisonExpression.java" afterPath="$PROJECT_DIR$/src/java/ognl/ComparisonExpression.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/BooleanExpression.java" afterPath="$PROJECT_DIR$/src/java/ognl/BooleanExpression.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTAnd.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTAnd.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTList.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTList.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTInstanceof.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTInstanceof.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTProperty.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTProperty.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTUnsignedShiftRight.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTUnsignedShiftRight.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ObjectPropertyAccessor.java" afterPath="$PROJECT_DIR$/src/java/ognl/ObjectPropertyAccessor.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTCtor.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTCtor.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTStaticField.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTStaticField.java" />
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/java/ognl/ASTChain.java" afterPath="$PROJECT_DIR$/src/java/ognl/ASTChain.java" />
     </list>
   </component>
   <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
           <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
         </PATH_ELEMENT>
       </PATH>
-      <PATH>
-        <PATH_ELEMENT>
-          <option name="myItemId" value="OGNL" />
-          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
-        </PATH_ELEMENT>
-        <PATH_ELEMENT>
-          <option name="myItemId" value="OGNL" />
-          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
-        </PATH_ELEMENT>
-        <PATH_ELEMENT>
-          <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$" />
-          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
-        </PATH_ELEMENT>
-        <PATH_ELEMENT>
-          <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$/src" />
-          <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
-        </PATH_ELEMENT>
-      </PATH>
     </subPane>
   </component>
   <component name="ProjectReloadState">
     <option name="referencePos" value="0" />
     <option name="showLabels" value="true" />
   </component>
-  <component name="RunManager" selected="JUnit.TestOgnlRuntime">
-    <tempConfiguration default="false" name="TestOgnlRuntime" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
-      <pattern value="ognl.*" />
+  <component name="RunManager" selected="JUnit.MethodTest">
+    <tempConfiguration default="false" name="MethodTest" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
+      <pattern value="org.ognl.test.*" />
       <module name="OGNL" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
       <option name="ALTERNATIVE_JRE_PATH" value="/usr/local/jdk1.6.0_02" />
-      <option name="PACKAGE_NAME" value="ognl" />
-      <option name="MAIN_CLASS_NAME" value="ognl.TestOgnlRuntime" />
+      <option name="PACKAGE_NAME" value="org.ognl.test" />
+      <option name="MAIN_CLASS_NAME" value="org.ognl.test.MethodTest" />
       <option name="METHOD_NAME" value="" />
       <option name="TEST_OBJECT" value="class" />
       <option name="VM_PARAMETERS" value="" />
     <option name="PERFORM_EDIT_IN_BACKGROUND" value="true" />
     <option name="PERFORM_ADD_REMOVE_IN_BACKGROUND" value="true" />
     <option name="FORCE_NON_EMPTY_COMMENT" value="false" />
-    <option name="LAST_COMMIT_MESSAGE" value="Fixes OGNL-103.  OgnlRuntime.getReadMethod wasn't checking for is/has - causing common boolean getters to sometimes return the wrong getter." />
+    <option name="LAST_COMMIT_MESSAGE" value="Fixes OGNL-106.  Wasn't checking for null in ASTMethod.&#10;&#10;Also refactored exception catching logic so that more exceptions aren't needlessly added on to the exception stack when catching Throwables." />
     <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
     <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" />
     <option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" />
     <option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
     <option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
     <option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
-    <MESSAGE value="Fixes OGNL-85.  Error with type conversion in constructor calls.  Finally refactored ASTCtor to really dig through the available constructors and more thoroughly convert parameter types when possible." />
-    <MESSAGE value="Fixes OGNL-86.  NumericExpression superclass was incorrectly using _currentChain context values stored during chained subexpressions for non ASTMethod children." />
     <MESSAGE value="Cleaning up source / javadocs / etc in preparation for release.  Tried unsuccessfully to get docbook running happily." />
     <MESSAGE value="Got docbook working finally.  Has to be run with 1.4 jre." />
     <MESSAGE value="Fixes OGNL-89.  ASTCtor was calling ExpressionCompiler.getRootExpression() on child expression of ASTRootVarRef - which was also doing the same exact thing on itself." />
     <MESSAGE value="Added support for enum constant expressions to help fix OGNL-106 but can't be sure if it's fixed or not because of insufficient data." />
     <MESSAGE value="Fixes OGNL-104.  ComparisonExpression base class was checking specifically for Number.class instances when figuring out when to do conversions but this isn't necessary as that specific kind of comparison conversion is done already in the NumericExpression base class." />
     <MESSAGE value="Fixes OGNL-103.  OgnlRuntime.getReadMethod wasn't checking for is/has - causing common boolean getters to sometimes return the wrong getter." />
+    <MESSAGE value="Fixes OGNL-105. Indexed object method calls attempting to use reflection (by calling methods using the name of a return property expression) were failing.. Added smarter logic to ObjectPropertyAccessor to try getting the read method using the context current object value if the passed in string index method couldn't be found." />
+    <MESSAGE value="Fixes OGNL-106.  Wasn't checking for null in ASTMethod.&#10;&#10;Also refactored exception catching logic so that more exceptions aren't needlessly added on to the exception stack when catching Throwables." />
   </component>
   <component name="VssConfiguration">
     <option name="CLIENT_PATH" value="" />
     <option name="myLastEditedConfigurable" />
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/NumericExpression.java">
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTOr.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="54" column="72" selection-start="1207" selection-end="1207" vertical-scroll-proportion="0.573443">
+        <state line="170" column="29" selection-start="6100" selection-end="6100" vertical-scroll-proportion="0.67639595">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTProperty.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="530" column="9" selection-start="21966" selection-end="21966" vertical-scroll-proportion="0.6954315">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTStaticField.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="188" column="13" selection-start="5939" selection-end="5939" vertical-scroll-proportion="0.61928934">
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTStaticMethod.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="223" column="0" selection-start="8634" selection-end="8634" vertical-scroll-proportion="0.67639595">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTTest.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="123" column="51" selection-start="5307" selection-end="5307" vertical-scroll-proportion="0.7715736">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ASTUnsignedShiftRight.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="87" column="9" selection-start="3419" selection-end="3419" vertical-scroll-proportion="0.84771574">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/BooleanExpression.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="67" column="9" selection-start="1641" selection-end="1641" vertical-scroll-proportion="0.88578683">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/ComparisonExpression.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="47" column="53" selection-start="1472" selection-end="1472" vertical-scroll-proportion="0.46768507">
+        <state line="71" column="9" selection-start="2351" selection-end="2351" vertical-scroll-proportion="0.88578683">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/JavaCharStream.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="122" column="5" selection-start="3244" selection-end="3244" vertical-scroll-proportion="0.33375636">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/ListPropertyAccessor.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="234" column="0" selection-start="9067" selection-end="9067" vertical-scroll-proportion="0.23857868">
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/NumericExpression.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="61" column="9" selection-start="1362" selection-end="1362" vertical-scroll-proportion="0.39086294">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/ObjectPropertyAccessor.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="213" column="21" selection-start="7865" selection-end="7865" vertical-scroll-proportion="0.38977367">
+        <state line="297" column="9" selection-start="11664" selection-end="11664" vertical-scroll-proportion="0.88578683">
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/java/ognl/OgnlOps.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state line="641" column="8" selection-start="23597" selection-end="23597" vertical-scroll-proportion="0.50507617">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/enhance/ExpressionCompiler.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="757" column="0" selection-start="27188" selection-end="27188" vertical-scroll-proportion="0.673093">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/enhance/OgnlExpressionCompiler.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="38" column="0" selection-start="1505" selection-end="1505" vertical-scroll-proportion="0.41492036">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/Ognl.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="456" column="5" selection-start="18259" selection-end="18259" vertical-scroll-proportion="0.29337803">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/enhance/ExpressionAccessor.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="33" column="34" selection-start="919" selection-end="919" vertical-scroll-proportion="0.37720034">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/java/ognl/Node.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="92" column="10" selection-start="3744" selection-end="3744" vertical-scroll-proportion="0.7921207">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/enhance/TestExpressionCompiler.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="39" column="32" selection-start="924" selection-end="924" vertical-scroll-proportion="0.30176026">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyArithmeticTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="32" column="67" selection-start="1730" selection-end="1730" vertical-scroll-proportion="0.35205364">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Bean2.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="65" column="32" selection-start="2328" selection-end="2328" vertical-scroll-proportion="0.4526404">
+        <state line="466" column="10" selection-start="16757" selection-end="16757" vertical-scroll-proportion="0.5038071">
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/src/java/ognl/OgnlRuntime.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state line="2152" column="28" selection-start="80491" selection-end="80491" vertical-scroll-proportion="0.4082146">
-          <folding>
-            <element signature="imports" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/ognl/TestOgnlRuntime.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="71" column="0" selection-start="1941" selection-end="1941" vertical-scroll-proportion="0.4124057">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/objects/Root.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="456" column="9" selection-start="10978" selection-end="10978" vertical-scroll-proportion="0.5331098">
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/src/test/java/org/ognl/test/PropertyTest.java">
-      <provider selected="true" editor-type-id="text-editor">
-        <state line="108" column="56" selection-start="7068" selection-end="7068" vertical-scroll-proportion="0.37720034">
+        <state line="2370" column="0" selection-start="89142" selection-end="89142" vertical-scroll-proportion="0.06725888">
           <folding />
         </state>
       </provider>

src/java/ognl/ASTAdd.java

 package ognl;
 
 import ognl.enhance.ExpressionCompiler;
-import ognl.enhance.UnsupportedCompilationException;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
 
             return result;
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/ASTAnd.java

         } catch (NullPointerException e) {
             
             throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
         
         return result;
             
             context.setCurrentType(Object.class);
             
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
         
         return result;

src/java/ognl/ASTChain.java

                     context.put("_currentChain", result);
                 }
             }
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
         
         if (_lastType != null) {
                     context.put("_currentChain", result);
                 }
             }
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
         
         context.put("_lastChild", prevChild);

src/java/ognl/ASTCtor.java

 package ognl;
 
 import ognl.enhance.ExpressionCompiler;
-import ognl.enhance.UnsupportedCompilationException;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
             if (isArray)
                 context.put("_ctorClass", clazz);
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         try {
             context.setCurrentAccessor(clazz);
             context.setCurrentObject(ctorValue);
 
-        }catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         context.remove("_ctorClass");

src/java/ognl/ASTIn.java

             e.printStackTrace();
             
             throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
     

src/java/ognl/ASTInstanceof.java

 //--------------------------------------------------------------------------
 package ognl;
 
-import ognl.enhance.UnsupportedCompilationException;
-
 /**
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
             else
                 return _children[0].toGetSourceString(context, target) + " instanceof " + targetType;
             
-        } catch (Throwable t) { 
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
     

src/java/ognl/ASTList.java

                 result += value;
             }
 
-        }catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         context.setCurrentType(List.class);

src/java/ognl/ASTMethod.java

                         } else if ((NodeType.class.isInstance(_children[i])
                                 && ((NodeType)_children[i]).getGetterClass() != null 
                                 && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass()))
-                                || valueClass.isPrimitive()) {
-
+                                || (valueClass != null && valueClass.isPrimitive()))
+                        {
                             parmString = " ($w) " + parmString;
-                        } else if (valueClass.isPrimitive()) {
+                        } else if (valueClass != null && valueClass.isPrimitive())
+                        {
                             parmString = "($w) " + parmString;
                         }
                     }
                 }
             }
             
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         try {
                         } else if ((NodeType.class.isInstance(_children[i])
                                 && ((NodeType)_children[i]).getGetterClass() != null
                                 && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass()))
-                                || valueClass.isPrimitive()) {
-
+                                || (valueClass != null && valueClass.isPrimitive()))
+                        {
                             parmString = " ($w) " + parmString;
-                            
-                        } else if (valueClass.isPrimitive()) {
+                        } else if (valueClass != null && valueClass.isPrimitive()) 
+                        {
                             parmString = "($w) " + parmString;
                         }
                     }
                     result += parmString;
                 }
 
-                if (prevCast != null) {
-
+                if (prevCast != null)
+                {
                     context.put(ExpressionCompiler.PRE_CAST, prevCast);
                 }
             }
             
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         try {

src/java/ognl/ASTNot.java

 //--------------------------------------------------------------------------
 package ognl;
 
-import ognl.enhance.UnsupportedCompilationException;
-
 /**
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
 
             return "(! ognl.OgnlOps.booleanValue(" + srcString + ") )";
             
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/ASTNotIn.java

             e.printStackTrace();
             
             throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/ASTOr.java

             context.setCurrentObject(target);
             context.setCurrentType(Boolean.TYPE);
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException) t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return result;
 
             context.setCurrentType(Boolean.TYPE);
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException) t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return result;

src/java/ognl/ASTProperty.java

                 }
             }
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         // set known property types for NodeType interface when possible
                 }
             }
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         context.setCurrentObject(target);

src/java/ognl/ASTStaticField.java

 // --------------------------------------------------------------------------
 package ognl;
 
-import ognl.enhance.UnsupportedCompilationException;
-
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 
 
             context.setCurrentType(_getterClass);
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return className + "." + fieldName;
 
             context.setCurrentType(_getterClass);
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
-
+        
         return className + "." + fieldName;
     }
 }

src/java/ognl/ASTStaticMethod.java

                 context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass()));
             }
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return result;

src/java/ognl/ASTTest.java

         } catch (NullPointerException e) {
             
             // expected to happen in some instances
-            
             throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/ASTUnsignedShiftRight.java

 //--------------------------------------------------------------------------
 package ognl;
 
-import ognl.enhance.UnsupportedCompilationException;
-
 /**
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
             context.setCurrentType(Integer.TYPE);
             context.setCurrentObject(getValueBody(context, target));
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return result;

src/java/ognl/BooleanExpression.java

             e.printStackTrace();
             
             throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/ComparisonExpression.java

             // expected to happen in some instances
             
             throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/ListPropertyAccessor.java

 // --------------------------------------------------------------------------
 package ognl;
 
-import ognl.enhance.UnsupportedCompilationException;
-
 import java.lang.reflect.Method;
 import java.util.*;
 
 /**
  * Implementation of PropertyAccessor that uses numbers and dynamic subscripts as properties to
  * index into Lists.
- * 
+ *
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
 {
 
     public Object getProperty(Map context, Object target, Object name)
-        throws OgnlException
+            throws OgnlException
     {
         List list = (List) target;
 
         if (name instanceof String) {
             Object result = null;
-            
+
             if (name.equals("size")) {
                 result = new Integer(list.size());
             } else {
                     }
                 }
             }
-            
+
             return result;
         }
-        
-        if (name instanceof Number) 
+
+        if (name instanceof Number)
             return list.get(((Number) name).intValue());
-        
+
         if (name instanceof DynamicSubscript) {
             int len = list.size();
             switch(((DynamicSubscript) name).getFlag()) {
-            case DynamicSubscript.FIRST:
-                return len > 0 ? list.get(0) : null;
-            case DynamicSubscript.MID:
-                return len > 0 ? list.get(len / 2) : null;
-            case DynamicSubscript.LAST:
-                return len > 0 ? list.get(len - 1) : null;
-            case DynamicSubscript.ALL:
-                return new ArrayList(list);
+                case DynamicSubscript.FIRST:
+                    return len > 0 ? list.get(0) : null;
+                case DynamicSubscript.MID:
+                    return len > 0 ? list.get(len / 2) : null;
+                case DynamicSubscript.LAST:
+                    return len > 0 ? list.get(len - 1) : null;
+                case DynamicSubscript.ALL:
+                    return new ArrayList(list);
             }
         }
 
     }
 
     public void setProperty(Map context, Object target, Object name, Object value)
-        throws OgnlException
+            throws OgnlException
     {
         if (name instanceof String && ((String)name).indexOf("$") < 0) {
             super.setProperty(context, target, name, value);
         if (name instanceof DynamicSubscript) {
             int len = list.size();
             switch(((DynamicSubscript) name).getFlag()) {
-            case DynamicSubscript.FIRST:
-                if (len > 0) list.set(0, value);
-                return;
-            case DynamicSubscript.MID:
-                if (len > 0) list.set(len / 2, value);
-                return;
-            case DynamicSubscript.LAST:
-                if (len > 0) list.set(len - 1, value);
-                return;
-            case DynamicSubscript.ALL:
-            {
-                if (!(value instanceof Collection)) throw new OgnlException("Value must be a collection");
-                list.clear();
-                list.addAll((Collection) value);
-                return;
-            }
+                case DynamicSubscript.FIRST:
+                    if (len > 0) list.set(0, value);
+                    return;
+                case DynamicSubscript.MID:
+                    if (len > 0) list.set(len / 2, value);
+                    return;
+                case DynamicSubscript.LAST:
+                    if (len > 0) list.set(len - 1, value);
+                    return;
+                case DynamicSubscript.ALL:
+                {
+                    if (!(value instanceof Collection)) throw new OgnlException("Value must be a collection");
+                    list.clear();
+                    list.addAll((Collection) value);
+                    return;
+                }
             }
         }
-        
+
         throw new NoSuchPropertyException(target, name);
     }
-    
+
     public Class getPropertyClass(OgnlContext context, Object target, Object index)
     {
         if (index instanceof String) {
                 }
             }
         }
-        
+
         if (index instanceof Number)
             return Object.class;
-        
+
         return null;
     }
-    
+
     public String getSourceAccessor(OgnlContext context, Object target, Object index)
     {
         String indexStr = index.toString().replaceAll("\"", "");
-        
+
         if (index instanceof String) {
 
             if (indexStr.equals("size")) {
                 }
             }
         }
-        
+
         // TODO: This feels really inefficient, must be some better way
         // check if the index string represents a method on a custom class implementing java.util.List instead..
-        
+
         if (context.getCurrentObject() != null && !Number.class.isInstance(context.getCurrentObject())) {
 
             try {
 
                 if (m != null)
                     return super.getSourceAccessor(context, target, index);
-                
-            } catch (Throwable t) {
-                if (UnsupportedCompilationException.class.isInstance(t))
-                    throw (UnsupportedCompilationException) t;
-                else
-                    throw new RuntimeException(t);
+
+            } catch (Throwable t)
+            {
+                throw OgnlOps.castToRuntime(t);
             }
         }
 
 
         // need to convert to primitive for list index access
         // System.out.println("Curent type: " + context.getCurrentType() + " current object type " + context.getCurrentObject().getClass());
-        
+
         if (!context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) {
-            
+
             indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType());
         }  else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass())
                     && !context.getCurrentType().isPrimitive()) {
 
             indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")";
         }
-        
+
         context.setCurrentType(Object.class);
-        
+
         return ".get(" + indexStr + ")";
     }
 
     public String getSourceSetter(OgnlContext context, Object target, Object index)
     {
-        
+
         String indexStr = index.toString().replaceAll("\"", "");
-        
+
         // TODO: This feels really inefficient, must be some better way
         // check if the index string represents a method on a custom class implementing java.util.List instead..
         if (context.getCurrentObject() != null && !Number.class.isInstance(context.getCurrentObject())) {
                 if (m != null)
                     return super.getSourceSetter(context, target, index);
 
-            } catch (Throwable t) {
-                if (UnsupportedCompilationException.class.isInstance(t))
-                    throw (UnsupportedCompilationException) t;
-                else
-                    throw new RuntimeException(t);
+            } catch (Throwable t)
+            {
+                throw OgnlOps.castToRuntime(t);
             }
         }
 
 
             indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")";
         }
-        
+
         context.setCurrentType(Object.class);
-        
+
         return ".set(" + indexStr + ", $3)";
     }
 }

src/java/ognl/NumericExpression.java

 package ognl;
 
 import ognl.enhance.ExpressionCompiler;
-import ognl.enhance.UnsupportedCompilationException;
 
 
 /**
                 result += coerceToNumeric(str, context, _children[i]);
             }
             
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException)t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return result;

src/java/ognl/ObjectPropertyAccessor.java

 
             return m.getReturnType();
 
-        } catch (Throwable t) {
-            throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 
 
         } catch (Throwable t)
         {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException) t;
-            else
-                throw new RuntimeException(t);
+            throw OgnlOps.castToRuntime(t);
         }
     }
 
 
             return "." + m.getName() + "(" + conversion + ")";
 
-        } catch (Throwable t) {
-            if (UnsupportedCompilationException.class.isInstance(t))
-                throw (UnsupportedCompilationException) t;
-            else
-                throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
     }
 }

src/java/ognl/OgnlOps.java

     {
         return returnValue;
     }
+
+    /**
+     * Utility method that converts incoming exceptions to {@link RuntimeException} 
+     * instances - or casts them if they already are.
+     *
+     * @param t
+     *      The exception to cast.
+     * @return The exception cast to a {@link RuntimeException}.
+     */
+    public static RuntimeException castToRuntime(Throwable t)
+    {
+        if (RuntimeException.class.isInstance(t))
+            return (RuntimeException)t;
+        
+        return new RuntimeException(t);
+    }
 }

src/java/ognl/OgnlRuntime.java

             if (!name.startsWith("get"))
                 return OgnlRuntime.getReadMethod(target, "get" + name, numParms);
 
-        } catch (Throwable t) {
-            throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return null;
                 return OgnlRuntime.getReadMethod(target, "set" + name, numParms);
             }
 
-        } catch (Throwable t) {
-            throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return null;
                     return pds[i];
             }
 
-        } catch (Throwable t) {
-            throw new RuntimeException(t);
+        } catch (Throwable t)
+        {
+            throw OgnlOps.castToRuntime(t);
         }
 
         return null;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.