db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r289539 - in /db/derby/code/trunk/java/client/org/apache/derby/client/am: PreparedStatement.java ResultSet.java Statement.java
Date Fri, 16 Sep 2005 13:52:19 GMT
Author: kmarsden
Date: Fri Sep 16 06:52:14 2005
New Revision: 289539

URL: http://svn.apache.org/viewcvs?rev=289539&view=rev
Log:
DERBY-557 
Client driver gets OutOfMemoryError when re-executing statement without closing ResultSet


Attached a patch which fixes the bug. The patch ensures that the ResultSets associated with
a Statement/PreparedStatement are removed from CommitAndRollbackListeners_ in org.apache.derby.client.am.Connection
when the statement is re-executed.

I have run derbyall with only one error (wrong length of encryption key, not related to the
patch). I have also run the program in the problem description (both with Statement and PreparedStatement),
and the memory usage doesn't increase over time.

		Contributed by Knut Anders Hatlen
	

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=289539&r1=289538&r2=289539&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Fri
Sep 16 06:52:14 2005
@@ -1367,7 +1367,7 @@
                 connection_.completeTransactionStart();
             }
 
-            super.markResultSetsClosed();
+            super.markResultSetsClosed(true); // true means remove from list of commit and
rollback listeners
 
             switch (sqlMode_) {
             case isUpdate__:

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java?rev=289539&r1=289538&r2=289539&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java Fri Sep 16 06:52:14
2005
@@ -388,8 +388,7 @@
                 statement_.resultSetCommitting(this);
             }
         } finally {
-            markClosed();
-            connection_.CommitAndRollbackListeners_.remove(this);
+            markClosed(true);
         }
 
         if (statement_.openOnClient_ && statement_.isCatalogQuery_) {
@@ -2989,12 +2988,31 @@
         }
     }
 
+    /**
+     * Mark this ResultSet as closed. The ResultSet will not be
+     * removed from the commit and rollback listeners list in
+     * <code>org.apache.derby.client.am.Connection</code>.
+     */
     void markClosed() {
+        markClosed(false);
+    }
+
+    /**
+     * Mark this ResultSet as closed.
+     *
+     * @param removeListener if true the ResultSet will be removed
+     * from the commit and rollback listeners list in
+     * <code>org.apache.derby.client.am.Connection</code>.
+     */
+    void markClosed(boolean removeListener) {
         openOnClient_ = false;
         openOnServer_ = false;
         statement_.resetCursorNameAndRemoveFromWhereCurrentOfMappings(); // for SELECT...FOR
UPDATE queries
         statement_.removeClientCursorNameFromCache();
         markPositionedUpdateDeletePreparedStatementsClosed();
+        if (removeListener) {
+            connection_.CommitAndRollbackListeners_.remove(this);
+        }
     }
 
     void markClosedOnServer() {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java?rev=289539&r1=289538&r2=289539&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java Fri Sep 16 06:52:14
2005
@@ -1393,20 +1393,38 @@
         }
     }
 
+    /**
+     * Mark all ResultSets associated with this statement as
+     * closed. The ResultSets will not be removed from the commit and
+     * rollback listeners list in
+     * <code>org.apache.derby.client.am.Connection</code>.
+     */
     void markResultSetsClosed() {
+        markResultSetsClosed(false);
+    }
+
+    /**
+     * Mark all ResultSets associated with this statement as
+     * closed.
+     *
+     * @param removeListener if true the ResultSets will be removed
+     * from the commit and rollback listeners list in
+     * <code>org.apache.derby.client.am.Connection</code>.
+     */
+    void markResultSetsClosed(boolean removeListener) {
         if (resultSetList_ != null) {
             for (int i = 0; i < resultSetList_.length; i++) {
                 if (resultSetList_[i] != null) {
-                    resultSetList_[i].markClosed();
+                    resultSetList_[i].markClosed(removeListener);
                 }
                 resultSetList_[i] = null;
             }
         }
         if (generatedKeysResultSet_ != null) {
-            generatedKeysResultSet_.markClosed();
+            generatedKeysResultSet_.markClosed(removeListener);
         }
         if (resultSet_ != null) {
-            resultSet_.markClosed();
+            resultSet_.markClosed(removeListener);
         }
         resultSet_ = null;
         resultSetList_ = null;
@@ -1544,7 +1562,7 @@
                 connection_.completeTransactionStart();
             }
 
-            markResultSetsClosed();
+            markResultSetsClosed(true); // true means remove from list of commit and rollback
listeners
             markClosedOnServer();
             section_ = newSection;
 



Mime
View raw message