db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r387264 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/context/ContextService.java impl/services/monitor/BaseMonitor.java
Date Mon, 20 Mar 2006 17:53:11 GMT
Author: djd
Date: Mon Mar 20 09:53:09 2006
New Revision: 387264

URL: http://svn.apache.org/viewcvs?rev=387264&view=rev
Log:
DERBY-1095 Cleanup ContextManagers created during database boot.
Add some comments and synchronization to ContextService.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.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=387264&r1=387263&r2=387264&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 Mar 20 09:53:09 2006
@@ -158,9 +158,22 @@
 	*/
 	private ThreadLocal threadContextList = new ThreadLocal();
 
+    /**
+     * Collection of all ContextManagers that are open
+     * in the complete Derby system. A ContextManager is
+     * added when it is created with newContextManager and
+     * removed when the session is closed.
+     * 
+     * @see #newContextManager()
+     * @see SystemContext#cleanupOnError(Throwable)
+     */
 	private HashSet allContexts;
 
-	// don't want any instances
+    /**
+     * Create a new ContextService for a Derby system.
+     * Only a single system is active at any time.
+     *
+     */
 	public ContextService() {
 
 		// find the error stream
@@ -179,10 +192,14 @@
 		// For some unknown reason, the ContextManager and
 		// ContextService objects will not be garbage collected
 		// without the next two lines.
-		factory.allContexts = null;
-		factory.threadContextList = null;
-
-		ContextService.factory = null;
+        ContextService fact = ContextService.factory;
+        if (fact != null) {
+            synchronized (fact) {
+                fact.allContexts = null;
+                fact.threadContextList = null;
+                ContextService.factory = null;
+            }
+        }
 	}
 
 	public static ContextService getFactory() {
@@ -495,7 +512,7 @@
 
 		synchronized (this) {
 			allContexts.add(cm);
-
+            
 			if (SanityManager.DEBUG) {
 
 				if (SanityManager.DEBUG_ON("memoryLeakTrace")) {
@@ -531,8 +548,13 @@
 		}
 	}
 
-    synchronized void removeContext( ContextManager cm)
+    /**
+     * Remove a ContextManager from the list of all active
+     * contexts managers.
+     */
+    synchronized void removeContext(ContextManager cm)
     {
-        allContexts.remove( cm);
+        if (allContexts != null)
+            allContexts.remove( cm);
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=387264&r1=387263&r2=387264&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
Mon Mar 20 09:53:09 2006
@@ -1836,7 +1836,10 @@
 						BaseMonitor.removeRuntimeProperties(properties), false);
 				usProperties.setServiceBooted();
 			}
-
+            
+            if (cm != previousCM)
+                cm.cleanupOnError(StandardException.closeException());
+            
 		} catch (Throwable t) {
 
 			// ensure that the severity will shutdown the service



Mime
View raw message