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

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@895118 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
index 06e15fb..29fbd8e 100644
--- a/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
+++ b/src/java/org/apache/commons/lang3/exception/ExceptionUtils.java
@@ -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 (cause == null) {
-                cause = getCauseUsingFieldName(throwable, "detail");
+        if (methodNames == null) {
+            synchronized(CAUSE_METHOD_NAMES_LOCK) {
+                methodNames = CAUSE_METHOD_NAMES;
             }
         }
-        return cause;
+
+        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 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