Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46408
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Dec 2008 14:28:06 +0000 (14:28 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Dec 2008 14:28:06 +0000 (14:28 +0000)
Don't make assumptions about exception type

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

java/org/apache/catalina/security/SecurityUtil.java

index 3afbd92..b046a33 100644 (file)
@@ -299,9 +299,14 @@ public final class SecurityUtil{
             }
 
             Subject.doAsPrivileged(subject, pea, null);       
-       } catch( PrivilegedActionException pe) {
-            Throwable e = ((InvocationTargetException)pe.getException())
+        } catch( PrivilegedActionException pe) {
+            Throwable e;
+            if (pe.getException() instanceof InvocationTargetException) {
+                e = ((InvocationTargetException)pe.getException())
                                 .getTargetException();
+            } else {
+                e = pe;
+            }
             
             if (log.isDebugEnabled()){
                 log.debug(sm.getString("SecurityUtil.doAsPrivilege"), e);