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 da...@apache.org on 2014/04/04 14:46:49 UTC
svn commit: r1584638 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
tests/lang/NestedCommitTest.java util/Triggers.java
Author: dag
Date: Fri Apr 4 12:46:49 2014
New Revision: 1584638
URL: http://svn.apache.org/r1584638
Log:
DERBY-6516 Convert lang/nestedCommit.sql to JUnit NestedCommitTest
Patch derby-6516-gc to fix the intermittent error we saw on this
issue. The patch makes sure we close the result set for the statement
'values doConnCommitInt()' when executed inside a stored
procedure. Previously, it was executed by the stored procedure
"doConnStmtIntNoRS". We changed that to "doConnStmtInt" since this
statement does indeed have a result set.
The supporting procedure in Triggers#doConnStmt also had to be fixed a
bit, since this particular result set closes itself by performing a
commit inside the store procedure, which led the second ResultSet#next
to throw XLC16.
With the patch, I do not see the original error even when disabling the
explicit garbage collection (Java option -XX:+DisableExplicitGC).
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NestedCommitTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/Triggers.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NestedCommitTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NestedCommitTest.java?rev=1584638&r1=1584637&r2=1584638&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NestedCommitTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/NestedCommitTest.java Fri Apr 4 12:46:49 2014
@@ -88,7 +88,7 @@ public final class NestedCommitTest exte
+ " DYNAMIC RESULT SETS 0 LANGUAGE JAVA "
+ " EXTERNAL NAME "
+ "'org.apache.derbyTesting.functionTests.util.Triggers"
- + ".doConnStmtNoRS' "
+ + ".doConnStmt' "
+ " CONTAINS SQL"
+ " PARAMETER STYLE JAVA");
@@ -101,7 +101,7 @@ public final class NestedCommitTest exte
st.executeUpdate("CREATE FUNCTION doConnStmtInt(TEXT CHAR(50)) "
+ " RETURNS INT EXTERNAL NAME "
+ "'org.apache.derbyTesting.functionTests.util.Triggers"
- + ".doConnStmtIntNoRS' "
+ + ".doConnStmtInt' "
+ " LANGUAGE JAVA PARAMETER STYLE JAVA");
st.executeUpdate("create table x (x int)");
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/Triggers.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/Triggers.java?rev=1584638&r1=1584637&r2=1584638&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/Triggers.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/Triggers.java Fri Apr 4 12:46:49 2014
@@ -21,17 +21,16 @@
package org.apache.derbyTesting.functionTests.util;
-import org.apache.derby.iapi.db.*;
import java.sql.*;
-import java.math.BigDecimal;
-import java.math.BigInteger;
/**
* Methods for testing triggers
*/
public class Triggers
{
- private Triggers()
+ private static final String RESULT_SET_NOT_OPEN = "XCL16";
+
+ private Triggers()
{
}
@@ -93,9 +92,18 @@ public class Triggers
if (stmt.execute(text))
{
ResultSet rs = stmt.getResultSet();
- while (rs.next())
- {}
- rs.close();
+ try {
+ while (rs.next()) {}
+ } catch (SQLException e) {
+ if (RESULT_SET_NOT_OPEN.equals(e.getSQLState())) {
+ // Some side effect (stored proc?) made the rs close,
+ // bail out
+ } else {
+ throw e;
+ }
+ } finally {
+ rs.close();
+ }
}
stmt.close();
conn.close();