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 ka...@apache.org on 2014/02/10 15:28:27 UTC

svn commit: r1566635 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: GenericPreparedStatement.java GenericStatement.java

Author: kahatlen
Date: Mon Feb 10 14:28:27 2014
New Revision: 1566635

URL: http://svn.apache.org/r1566635
Log:
DERBY-2380: Make the generated class eligible for gc once the statement is invalidated

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java?rev=1566635&r1=1566634&r2=1566635&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java Mon Feb 10 14:28:27 2014
@@ -135,7 +135,7 @@ public class GenericPreparedStatement
 	private int inUseCount;
 
 	// true if the statement is being compiled.
-	boolean compilingStatement;
+    private boolean compilingStatement;
 
     /** True if the statement was invalidated while it was being compiled. */
     boolean invalidatedWhileCompiling;
@@ -226,6 +226,29 @@ public class GenericPreparedStatement
         return isValid && (activationClass != null) && !compilingStatement;
     }
 
+    /** Check if this statement is currently being compiled. */
+    final synchronized boolean isCompiling() {
+        return compilingStatement;
+    }
+
+    /**
+     * Signal that the statement is about to be compiled. This will block
+     * others from attempting to compile it.
+     */
+    final synchronized void beginCompiling() {
+        compilingStatement = true;
+        setActivationClass(null);
+    }
+
+    /**
+     * Signal that we're done compiling the statement and unblock others
+     * that are waiting for the compilation to finish.
+     */
+    final synchronized void endCompiling() {
+        compilingStatement = false;
+        notifyAll();
+    }
+
 	public void rePrepare(LanguageConnectionContext lcc) 
 		throws StandardException {
 		if (!upToDate()) {
@@ -835,7 +858,7 @@ recompileOutOfDatePlan:
 			isValid = false;
 
 			// block compiles while we are invalidating
-			compilingStatement = true;
+            beginCompiling();
 		}
 
 		try {
@@ -870,10 +893,7 @@ recompileOutOfDatePlan:
 				}
 			}
 		} finally {
-			synchronized (this) {
-				compilingStatement = false;
-				notifyAll();
-			}
+            endCompiling();
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java?rev=1566635&r1=1566634&r2=1566635&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java Mon Feb 10 14:28:27 2014
@@ -266,7 +266,7 @@ public class GenericStatement
 					return preparedStmt;
 				}
 
-				if (!preparedStmt.compilingStatement) {
+                if (!preparedStmt.isCompiling()) {
 					break;
 				}
 
@@ -277,8 +277,7 @@ public class GenericStatement
 				}
 			}
 
-			preparedStmt.compilingStatement = true;
-			preparedStmt.setActivationClass(null);
+            preparedStmt.beginCompiling();
 		}
 
 		try {
@@ -633,10 +632,7 @@ public class GenericStatement
 		}
 		finally
 		{
-			synchronized (preparedStmt) {
-				preparedStmt.compilingStatement = false;
-				preparedStmt.notifyAll();
-			}
+            preparedStmt.endCompiling();
 		}
 
 		lcc.commitNestedTransaction();