You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2014/01/31 22:08:08 UTC
svn commit: r1563257 - in
/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src: changes/changes.xml
main/java/org/apache/commons/dbcp/PoolableConnection.java
Author: markt
Date: Fri Jan 31 21:08:08 2014
New Revision: 1563257
URL: http://svn.apache.org/r1563257
Log:
Fix DBCP-391
Ensure that the close state of a pooled connection and the underlying connection is consistent when the underlying connection is closed as a result of an error condition.
Modified:
commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml
commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/PoolableConnection.java
Modified: commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml?rev=1563257&r1=1563256&r2=1563257&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml (original)
+++ commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml Fri Jan 31 21:08:08 2014
@@ -78,6 +78,11 @@ The <action> type attribute can be add,u
Fix threading issue when using multiple instances of the
SharedPoolDataSource concurrently.
</action>
+ <action dev="markt" issue="DBCP-391" type="fix">
+ Ensure that the close state of a pooled connection and the underlying
+ connection is consistent when the underlying connection is closed as a
+ result of an error condition.
+ </action>
</release>
<release version="1.4.1" date="TBD" description="TBD">
<action dev="psteitz" issue="DBCP-367" type="fix" due-to="Ken Tatsushita">
Modified: commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/PoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/PoolableConnection.java?rev=1563257&r1=1563256&r2=1563257&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/PoolableConnection.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/PoolableConnection.java Fri Jan 31 21:08:08 2014
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -58,6 +58,24 @@ public class PoolableConnection extends
}
+ @Override
+ public boolean isClosed() throws SQLException {
+ if (_closed) {
+ return true;
+ }
+
+ if (getDelegateInternal().isClosed()) {
+ // Something has gone wrong. The underlying connection has been
+ // closed without the connection being returned to the pool. Return
+ // it now.
+ close();
+ return true;
+ }
+
+ return false;
+ }
+
+
/**
* Returns me to my pool.
*/
@@ -108,11 +126,11 @@ public class PoolableConnection extends
// pool is closed, so close the connection
passivate();
getInnermostDelegate().close();
- } catch (Exception ie) {
- // DO NOTHING, "Already closed" exception thrown below
+ } catch (Exception e) {
+ throw (SQLException) new SQLException("Cannot close connection (invalidating pooled object failed)").initCause(e);
}
- throw new SQLException("Already closed.");
}
+ _closed = true;
}
/**