db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r384900 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/context/ iapi/services/loader/ impl/db/ impl/sql/execute/ jdbc/
Date Fri, 10 Mar 2006 19:10:51 GMT
Author: djd
Date: Fri Mar 10 11:10:49 2006
New Revision: 384900

URL: http://svn.apache.org/viewcvs?rev=384900&view=rev
Log:
DERBY-1095 (partial) Ensure on a close connection/session contexts are popped off the
context manager. This ensures that references to database wide objects
are not maintained after a close connection.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/Context.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactoryContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/Context.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/Context.java?rev=384900&r1=384899&r2=384900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/Context.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/Context.java Fri
Mar 10 11:10:49 2006
@@ -87,6 +87,13 @@
 	 * context manager. If there are no other references
 	 * to the context, removing itself from the manager
 	 * equates to freeing it.
+     * <BR>
+     * On an exception that is session severity or greater
+     * the Context must push itself off the stack. This is
+     * to ensure that after a session has been closed there
+     * are no Contexts on the stack that potentially hold
+     * references to objects, thus delaying their garbage
+     * collection.
 	 * <p>
 	 * Contexts must release all their resources before
 	 * removing themselves from their context manager.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java?rev=384900&r1=384899&r2=384900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java
Fri Mar 10 11:10:49 2006
@@ -42,6 +42,8 @@
 			int severity = se.getSeverity();
 			if (severity < ExceptionSeverity.SESSION_SEVERITY)
 				return;
+            
+            popMe();
 
 			if (severity >= ExceptionSeverity.SYSTEM_SEVERITY)
 				doShutdown = true;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactoryContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactoryContext.java?rev=384900&r1=384899&r2=384900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactoryContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassFactoryContext.java
Fri Mar 10 11:10:49 2006
@@ -23,29 +23,42 @@
 import org.apache.derby.iapi.services.context.ContextImpl;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.property.PersistentSet;
+import org.apache.derby.iapi.error.ExceptionSeverity;
 import org.apache.derby.iapi.error.StandardException;
+
 /**
+ * Context that provides the correct ClassFactory for the
+ * current service. Allows stateless code to obtain the
+ * correct class loading scheme.
 */
-
 public abstract class ClassFactoryContext extends ContextImpl {
 
 	public static final String CONTEXT_ID = "ClassFactoryContext";
 
 	private final ClassFactory cf;
 
-	public ClassFactoryContext(ContextManager cm, ClassFactory cf) {
+	protected ClassFactoryContext(ContextManager cm, ClassFactory cf) {
 
 		super(cm, CONTEXT_ID);
 
 		this.cf = cf;
 	}
 
-	public ClassFactory getClassFactory() {
+	public final ClassFactory getClassFactory() {
 		return cf;
 	}
 
+    /**
+     * Get the lock compatibility space to use for the
+     * transactional nature of the class loading lock.
+     * Used when the classpath changes or a database
+     * jar file is installed, removed or replaced.
+     */
 	public abstract Object getLockSpace() throws StandardException;
 
+    /**
+     * Get the set of properties stored with this service.
+    */
 	public abstract PersistentSet getPersistentSet() throws StandardException;
 
 	/**
@@ -54,5 +67,17 @@
 	*/
 	public abstract JarReader getJarReader();
 
-	public void cleanupOnError(Throwable error) {}
+    /**
+     * Handle any errors. Only work here is to pop myself
+     * on a session or greater severity error.
+     */
+	public final void cleanupOnError(Throwable error) {
+        if (error instanceof StandardException) {
+
+            StandardException se = (StandardException) error;
+            
+            if (se.getSeverity() >= ExceptionSeverity.SESSION_SEVERITY)
+                popMe();
+        }
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java?rev=384900&r1=384899&r2=384900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/DatabaseContextImpl.java Fri
Mar 10 11:10:49 2006
@@ -33,7 +33,7 @@
 /**
 	A context that shutdowns down the database on a databsae exception.
 */
-class DatabaseContextImpl extends ContextImpl implements DatabaseContext
+final class DatabaseContextImpl extends ContextImpl implements DatabaseContext
 {
 
 	private final Database	db;
@@ -46,10 +46,18 @@
 	public void cleanupOnError(Throwable t) {
 		if (!(t instanceof StandardException)) return;
 		StandardException se = (StandardException)t;
-		if (se.getSeverity() != ExceptionSeverity.DATABASE_SEVERITY) return;
-		popMe();
-		ContextService.getFactory().notifyAllActiveThreads(this);
-		Monitor.getMonitor().shutdown(db);
+
+        // Ensure the context is popped if the session is
+        // going away.
+        if (se.getSeverity() < ExceptionSeverity.SESSION_SEVERITY)
+            return;
+
+        popMe();
+        
+        if (se.getSeverity() == ExceptionSeverity.DATABASE_SEVERITY) {
+		    ContextService.getFactory().notifyAllActiveThreads(this);
+		    Monitor.getMonitor().shutdown(db);
+        }
 	}
 
 	public boolean equals(Object other) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionContext.java?rev=384900&r1=384899&r2=384900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericExecutionContext.java
Fri Mar 10 11:10:49 2006
@@ -160,8 +160,16 @@
 		if (error instanceof StandardException) {
 
 			StandardException se = (StandardException) error;
-			if (se.getSeverity() > ExceptionSeverity.STATEMENT_SEVERITY)
-				return;
+            int severity = se.getSeverity();
+            if (severity >= ExceptionSeverity.SESSION_SEVERITY)
+            {
+               popMe();
+               return;
+            }
+			if (severity > ExceptionSeverity.STATEMENT_SEVERITY)
+            {
+ 				return;
+            }
 
 
 			if (sourceRS != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java?rev=384900&r1=384899&r2=384900&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java Fri Mar
10 11:10:49 2006
@@ -88,6 +88,11 @@
 		if (t instanceof StandardException) {
 
 			StandardException se = (StandardException) t;
+            
+            if (se.getSeverity() >= ExceptionSeverity.SESSION_SEVERITY) {
+                popMe();
+                return;
+            }
 
 			if (se.getSeverity() == ExceptionSeverity.TRANSACTION_SEVERITY) {
 



Mime
View raw message