db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r616575 - /db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
Date Wed, 30 Jan 2008 01:12:02 GMT
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)



Mime
View raw message