Fix DBCP-472

Avoid potential infinite loops when checking if an SQLException is fatal
for a connection or not.

Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/0b5b1be8
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/0b5b1be8
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/0b5b1be8

Branch: refs/heads/master
Commit: 0b5b1be810baf881d835ef2a96d55f54f537a6a5
Parents: a204265
Author: Mark Thomas <ma...@apache.org>
Authored: Wed Nov 2 21:24:45 2016 +0000
Committer: Mark Thomas <ma...@apache.org>
Committed: Wed Nov 2 21:24:45 2016 +0000

----------------------------------------------------------------------
 src/changes/changes.xml                                        | 4 ++++
 src/main/java/org/apache/commons/dbcp2/PoolableConnection.java | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/0b5b1be8/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 72d368d..c03667c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -95,6 +95,10 @@ The <action> type attribute can be add,update,fix,remove.
         Correct the name of the configuration attribute
         softMinEvictableIdleTimeMillis.
       </action>
+      <action dev="markt" type="fix" issue="DBCP-472">
+        Avoid potential infinite loops when checking if an SQLException is 
fatal
+        for a connection or not.
+      </action>
     </release>
     <release version="2.1.1" date="6 Aug 2015" description=
 "This is a patch release, including bug fixes only.">

http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/0b5b1be8/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java 
b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
index 2773f4f..7424240 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
@@ -326,7 +326,8 @@ public class PoolableConnection extends 
DelegatingConnection<Connection>
             fatalException = _disconnectionSqlCodes == null ? 
sqlState.startsWith(Utils.DISCONNECTION_SQL_CODE_PREFIX)
                     || Utils.DISCONNECTION_SQL_CODES.contains(sqlState) : 
_disconnectionSqlCodes.contains(sqlState);
             if (!fatalException) {
-                if (e.getNextException() != null) {
+                SQLException nextException = e.getNextException();
+                if (nextException != null && nextException != e) {
                     fatalException = 
isDisconnectionSqlException(e.getNextException());
                 }
             }

Reply via email to