db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r616141 - /db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
Date Tue, 29 Jan 2008 02:26:03 GMT
Author: kmarsden
Date: Mon Jan 28 18:26:01 2008
New Revision: 616141

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

core fix contributed by Asif Shahid with further suggestions from Dan Debrunner 

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=616141&r1=616140&r2=616141&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 Mon Jan
28 18:26:01 2008
@@ -337,23 +337,8 @@
 		}
 	}
 
-	// my conneciton handle is being closed
-	public synchronized void notifyClose()
-	{
-		// tell my listeners I am closed 
-		if (eventListener != null && eventListener.size() > 0)
-		{
-			ConnectionEvent closeEvent = new ConnectionEvent(this);
 
-			for (Enumeration e = eventListener.elements();
-				 e.hasMoreElements(); )
-			{
-				ConnectionEventListener l =
-					(ConnectionEventListener)e.nextElement();
-				l.connectionClosed(closeEvent);
-			}
-		}
-	}
+       
 
 	final void checkActive() throws SQLException {
 		if (!isActive)
@@ -431,13 +416,28 @@
 	/**
 		Close called on BrokeredConnection. If this call
 		returns true then getRealConnection().close() will be called.
-
+		
+		Notify listners that connection is closed.
 		Don't close the underlying real connection as
 		it is pooled.
 	*/
-	public boolean closingConnection() throws SQLException {
-		notifyClose();
+	public synchronized boolean closingConnection() throws SQLException {	    
+		//DERBY-2142 - Null out the connection handle BEFORE notifying listeners.
 		currentConnectionHandle = null;
+		// tell my listeners I am closed 
+		if (eventListener != null && eventListener.size() > 0)
+		{
+			ConnectionEvent closeEvent = new ConnectionEvent(this);
+
+			for (Enumeration e = eventListener.elements();
+				 e.hasMoreElements(); )
+			{
+				ConnectionEventListener l =
+					(ConnectionEventListener)e.nextElement();
+				l.connectionClosed(closeEvent);
+			}
+		}
+
 		return false;
 	}
 



Mime
View raw message