db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r371506 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
Date Mon, 23 Jan 2006 09:45:12 GMT
Author: bernt
Date: Mon Jan 23 01:45:07 2006
New Revision: 371506

URL: http://svn.apache.org/viewcvs?rev=371506&view=rev
Log:
DERBY-23 Patch (DERBY-23-npe.diff) that addresses the NullPointerException messages from rawStoreDaemon
threads we. Submitted by Knut Anders Hatlen

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java?rev=371506&r1=371505&r2=371506&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
Mon Jan 23 01:45:07 2006
@@ -178,7 +178,13 @@
 
 		Thread me = Thread.currentThread();
 
-		Object list = threadContextList.get();
+		ThreadLocal tcl = threadContextList;
+		if (tcl == null) {
+			// The context service is already stopped.
+			return null;
+		}
+
+		Object list = tcl.get();
 
 		if (list instanceof ContextManager) {
 			
@@ -213,6 +219,13 @@
 */	}
 
 	public void resetCurrentContextManager(ContextManager cm) {
+		ThreadLocal tcl = threadContextList;
+
+		if (tcl == null) {
+			// The context service is already stopped.
+			return;
+		}
+
 		if (SanityManager.DEBUG) {
 
 			if (Thread.currentThread() != cm.activeThread) {
@@ -232,8 +245,8 @@
 			}
 
 			if (cm.activeCount > 0) {
-				if (threadContextList.get() != cm)
-					SanityManager.THROWASSERT("resetCurrentContextManager - invalid thread local " + Thread.currentThread()
+ " - object " + threadContextList.get());
+				if (tcl.get() != cm)
+					SanityManager.THROWASSERT("resetCurrentContextManager - invalid thread local " + Thread.currentThread()
+ " - object " + tcl.get());
 
 			}
 		}
@@ -244,7 +257,7 @@
 			return;
 		}
 
-		java.util.Stack stack = (java.util.Stack) threadContextList.get();
+		java.util.Stack stack = (java.util.Stack) tcl.get();
 
 		Object oldCM = stack.pop();
 
@@ -272,20 +285,27 @@
 			// all the context managers on the stack
 			// are the same so reduce to a simple count.
 			nextCM.activeCount = stack.size();
-			threadContextList.set(nextCM);
+			tcl.set(nextCM);
 		}
 	}
 
 	private boolean addToThreadList(Thread me, ContextManager associateCM) {
 
-		Object list = threadContextList.get();
+		ThreadLocal tcl = threadContextList;
+
+		if (tcl == null) {
+			// The context service is already stopped.
+			return false;
+		}
+
+		Object list = tcl.get();
 
 		if (associateCM == list)
 			return true;
 
 		if (list == null)
 		{
-			threadContextList.set(associateCM);
+			tcl.set(associateCM);
 			return true;
 		}
 
@@ -295,11 +315,11 @@
 			if (me == null)
 				me = Thread.currentThread();
 			if (threadsCM.activeThread != me) {
-				threadContextList.set(associateCM);
+				tcl.set(associateCM);
 				return true;
 			}
 			stack = new java.util.Stack();
-			threadContextList.set(stack);
+			tcl.set(stack);
 
 			for (int i = 0; i < threadsCM.activeCount; i++)
 			{



Mime
View raw message