You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2008/01/30 02:12:02 UTC

svn commit: r616575 - /db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java

Author: kmarsden
Date: Tue Jan 29 17:12:01 2008
New Revision: 616575

URL: http://svn.apache.org/viewvc?rev=616575&view=rev
Log:
DERBY-2142 NullPointerException while using XAConnection/PooledConnection in a heavily contended multithreaded scenario

Update code comments.
 

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java?rev=616575&r1=616574&r2=616575&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java Tue Jan 29 17:12:01 2008
@@ -417,12 +417,21 @@
 		Close called on BrokeredConnection. If this call
 		returns true then getRealConnection().close() will be called.
 		
-		Notify listners that connection is closed.
+	
+	Notify listners that connection is closed.
 		Don't close the underlying real connection as
 		it is pooled.
 	*/
 	public synchronized boolean closingConnection() throws SQLException {	    
-		//DERBY-2142 - Null out the connection handle BEFORE notifying listeners.
+		//DERBY-2142-Null out the connection handle BEFORE notifying listeners.
+		//At time of the callback the PooledConnection must be 
+		//disassociated from its previous logical connection.
+		//If not there is a risk that the Pooled
+		//Connection could be returned to the pool, ready for pickup by a 
+		//new thread. This new thread then might obtain a java.sql.Connection 
+		//whose reference might get assigned to the currentConnectionHandle 
+		//field, meanwhile the previous thread completes the close making 
+		//the newly assigned currentConnectionHandle null, resulting in an NPE.
 		currentConnectionHandle = null;
 		// tell my listeners I am closed 
 		if (eventListener != null && eventListener.size() > 0)