db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1566635 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: GenericPreparedStatement.java GenericStatement.java
Date Mon, 10 Feb 2014 14:28:27 GMT
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();



Mime
View raw message