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/29 03:26:03 UTC
svn commit: r616141 -
/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
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;
}