commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r895118 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
Date Sat, 02 Jan 2010 04:57:11 GMT
Author: bayard
Date: Sat Jan  2 04:57:10 2010
New Revision: 895118

URL: http://svn.apache.org/viewvc?rev=895118&view=rev
Log:
Removing SQLException usage per LANG-539. This leads to removing getCauseUsingWellKnownTypes
and dropping the optimization step for SQLException and InvocationTargetException; plus a
simplification of the code in getCause(String,String[]) for LANG-491

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java?rev=895118&r1=895117&r2=895118&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
Sat Jan  2 04:57:10 2010
@@ -22,7 +22,6 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -303,28 +302,24 @@
         if (throwable == null) {
             return null;
         }
-        Throwable cause = getCauseUsingWellKnownTypes(throwable);
-        if (cause == null) {
-            if (methodNames == null) {
-                synchronized(CAUSE_METHOD_NAMES_LOCK) {
-                    methodNames = CAUSE_METHOD_NAMES;
-                }
-            }
-            for (int i = 0; i < methodNames.length; i++) {
-                String methodName = methodNames[i];
-                if (methodName != null) {
-                    cause = getCauseUsingMethodName(throwable, methodName);
-                    if (cause != null) {
-                        break;
-                    }
-                }
+
+        if (methodNames == null) {
+            synchronized(CAUSE_METHOD_NAMES_LOCK) {
+                methodNames = CAUSE_METHOD_NAMES;
             }
+        }
 
-            if (cause == null) {
-                cause = getCauseUsingFieldName(throwable, "detail");
+        for (int i = 0; i < methodNames.length; i++) {
+            String methodName = methodNames[i];
+            if (methodName != null) {
+                Throwable cause = getCauseUsingMethodName(throwable, methodName);
+                if (cause != null) {
+                    return cause;
+                }
             }
         }
-        return cause;
+
+        return getCauseUsingFieldName(throwable, "detail");
     }
 
     /**
@@ -350,26 +345,6 @@
     }
 
     /**
-     * <p>Finds a <code>Throwable</code> for known types.</p>
-     * 
-     * <p>Uses <code>instanceof</code> checks to examine the exception,
-     * looking for well known types which could contain chained or
-     * wrapped exceptions.</p>
-     *
-     * @param throwable  the exception to examine
-     * @return the wrapped exception, or <code>null</code> if not found
-     */
-    private static Throwable getCauseUsingWellKnownTypes(Throwable throwable) {
-        if (throwable instanceof SQLException) {
-            return ((SQLException) throwable).getNextException();
-        } else if (throwable instanceof InvocationTargetException) {
-            return ((InvocationTargetException) throwable).getTargetException();
-        } else {
-            return null;
-        }
-    }
-
-    /**
      * <p>Finds a <code>Throwable</code> by method name.</p>
      *
      * @param throwable  the exception to examine



Mime
View raw message