Fix ClassCastException when we try to cast a
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 18 Sep 2008 17:08:10 +0000 (17:08 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 18 Sep 2008 17:08:10 +0000 (17:08 +0000)
NullPointerException to an ELException.
I still need to investigate where the NPE came from,
but simply casting seems unsafe in any case.

Use a cast if possible and recreate exception
otherwise.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@696716 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/lang/ExpressionBuilder.java

index 61d351c..006dca9 100644 (file)
@@ -132,7 +132,11 @@ public final class ExpressionBuilder implements NodeVisitor {
         try {
             node.accept(this);
         } catch (Exception e) {
-            throw (ELException) e;
+            if (e instanceof ELException) {
+                throw (ELException) e;
+            } else {
+                throw (new ELException(e));
+            }
         }
         if (this.fnMapper instanceof FunctionMapperFactory) {
             this.fnMapper = ((FunctionMapperFactory) this.fnMapper).create();