Issue Details (XML | Word | Printable)

Key: DBCP-216
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Phil Steitz
Reporter: Marcos Sanz
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Dbcp

Improvement of error recovery in KeyedCPDSConnectionFactory

Created: 13/Apr/07 02:54 PM   Updated: 12/Sep/09 09:23 PM
Return to search
Component/s: None
Affects Version/s: 1.2.2
Fix Version/s: 1.3

Time Tracking:
Not Specified

File Attachments:
  Size
File KeyedCPDSConnectionFactory.java.diff 2007-04-13 02:55 PM Marcos Sanz 2 kB
Environment: Windows XP, Java 1.5.0_06-b05, Sybase ASE 12.5.4, jConnect 6.0.5 EBF 13862, Commons Pool 1.3

Resolution Date: 12/Sep/09 09:23 PM


 Description  « Hide
Attached you'll find a patch that improves the recovery of the class in different error situations.

1. The addition of removeConnectionEventListener() in destroyObject() ensures that the listener is removed, which is not guaranteed to have happened upon call of destroyObject(). We are for sure not interested any more in events, since we are about to destroy.

2. The same addition is made to connectionClosed(). Additionally, we have substituted there the call to destroyObject() with a call to pool.invalidateObject(). This is necessary because otherwise the object is destroyed but not removed from the pool.

3. The same substitution is made in connectionErrorOccurred(), otherwise the object might remain in the pool.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #598045 Sun Nov 25 20:02:07 UTC 2007 psteitz Improved error recovery and listener cleanup in KeyedCPDSConnectionFactory.
* Substituted calls to destroyObject with _pool.invalidateObject on error to
  ensure pool active count is decremented on error events.
* Ensured that events from closed or invalid connections are ignored and
  listeners are cleaned up. Generalized validatingMap to "muteMap" (map of
  PoolableConnections from which events are ignored) and postponed cleanup
  of this and pcMap to take place in makeObject.
* Removed calls to removeConnectionEventListener from connection event handlers
  to eliminate potential for ConcurrentModificationExceptions. Added a cleanupMap
  to keep track of PoolablConnections that need to have listeners cleaned up.

JIRA: DBCP-216
Reported (and patched) by Marcos Sanz
Files Changed
MODIFY /commons/proper/dbcp/trunk/pom.xml
ADD /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/ConnectionPoolDataSourceProxy.java
ADD /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestKeyedCPDSConnectionFactory.java
MODIFY /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java
MODIFY /commons/proper/dbcp/trunk/xdocs/changes.xml
ADD /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/PooledConnectionProxy.java

Repository Revision Date User Message
ASF #814240 Sat Sep 12 21:20:59 UTC 2009 psteitz 1) Modified fix applied in r598045:
* Removed workaround to prevent ConcurrentModificationExceptions generated by PooledConnectionImpl's notifyListeners method.
* Changed PooledConnectionImpl notifyListeners to copy listeners and iterate over the copy instead of directly iterating over failfast Vector iterator.

2) Applied the same fix to CPDSConnectionFactory

Jira: DBCP-216
Files Changed
MODIFY /commons/proper/dbcp/trunk/pom.xml
MODIFY /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java
ADD /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestCPDSConnectionFactory.java
MODIFY /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/PooledConnectionImpl.java
MODIFY /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java
MODIFY /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/PooledConnectionProxy.java

Repository Revision Date User Message
ASF #814317 Sun Sep 13 14:26:15 UTC 2009 psteitz Updated DBCP-216 entry to reflect final fix.
Files Changed
MODIFY /commons/proper/dbcp/trunk/xdocs/changes.xml