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 kr...@apache.org on 2011/07/05 12:06:56 UTC
svn commit: r1142957 - in /db/derby/code/branches/10.7: ./
java/engine/org/apache/derby/jdbc/
java/testing/org/apache/derbyTesting/functionTests/tests/memory/
Author: kristwaa
Date: Tue Jul 5 10:06:55 2011
New Revision: 1142957
URL: http://svn.apache.org/viewvc?rev=1142957&view=rev
Log:
DERBY-4137: OOM issue using XA with timeouts
DERBY-5291: test failure: NullPointerException with J2ME (weme 6.2) in testDerby4137_TransactionTimeoutSpecifiedNotExceeded(org.apache.derbyTesting.functionTests.tests.memory.XAMemTest)
Merged fix cleanly from trunk (revisions 1138341 and 1136363).
Added:
db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java
- copied, changed from r1136363, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java
Modified:
db/derby/code/branches/10.7/ (props changed)
db/derby/code/branches/10.7/java/engine/org/apache/derby/jdbc/XATransactionState.java
db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 5 10:06:55 2011
@@ -1 +1 @@
-/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076387,1078461,1078693,1081072,1081455,1081568,1085078,1091000,1097247,1103681,1103718,1129136,1130632,1130895,1131272,1132664,1139449,1141924
+/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076387,1078461,1078693,1081072,1081455,1081568,1085078,1091000,1097247,1103681,1103718,1129136,1130632,1130895,1131272,1132664,1136363,1138341,1139449,1141924
Modified: db/derby/code/branches/10.7/java/engine/org/apache/derby/jdbc/XATransactionState.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/engine/org/apache/derby/jdbc/XATransactionState.java?rev=1142957&r1=1142956&r2=1142957&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/engine/org/apache/derby/jdbc/XATransactionState.java (original)
+++ db/derby/code/branches/10.7/java/engine/org/apache/derby/jdbc/XATransactionState.java Tue Jul 5 10:06:55 2011
@@ -90,17 +90,29 @@ final class XATransactionState extends C
/** The implementation of TimerTask to cancel a global transaction. */
- private class CancelXATransactionTask extends TimerTask {
+ private static class CancelXATransactionTask extends TimerTask {
- /** Creates the cancelation object to be passed to a timer. */
- public CancelXATransactionTask() {
- XATransactionState.this.timeoutTask = this;
+ private XATransactionState xaState;
+
+ /**
+ * Creates the cancellation task to be passed to a timer.
+ *
+ * @param xaState the XA state object for the transaction to cancel
+ */
+ public CancelXATransactionTask(XATransactionState xaState) {
+ this.xaState = xaState;
+ }
+
+ public boolean cancel() {
+ // nullify reference to reduce memory footprint of canceled tasks
+ xaState = null;
+ return super.cancel();
}
/** Runs the cancel task of the global transaction */
public void run() {
try {
- XATransactionState.this.cancel(MessageId.CONN_XA_TRANSACTION_TIMED_OUT);
+ xaState.cancel(MessageId.CONN_XA_TRANSACTION_TIMED_OUT);
} catch (Throwable th) {
Monitor.logThrowable(th);
}
@@ -313,10 +325,10 @@ final class XATransactionState extends C
// schedule a time out task if the timeout was specified
if (timeoutMillis > 0) {
// take care of the transaction timeout
- TimerTask cancelTask = new CancelXATransactionTask();
TimerFactory timerFactory = Monitor.getMonitor().getTimerFactory();
Timer timer = timerFactory.getCancellationTimer();
- timer.schedule(cancelTask, timeoutMillis);
+ timeoutTask = new CancelXATransactionTask(this);
+ timer.schedule(timeoutTask, timeoutMillis);
} else {
timeoutTask = null;
}
@@ -354,6 +366,7 @@ final class XATransactionState extends C
synchronized void xa_finalize() {
if (timeoutTask != null) {
timeoutTask.cancel();
+ timeoutTask = null;
}
performTimeoutRollback = false;
}
Copied: db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java (from r1136363, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java?p2=db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java&r1=1136363&r2=1142957&rev=1142957&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java (original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java Tue Jul 5 10:06:55 2011
@@ -30,9 +30,11 @@ import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import junit.framework.Test;
+import junit.framework.TestSuite;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.J2EEDataSource;
+import org.apache.derbyTesting.junit.JDBC;
import org.apache.derbyTesting.junit.TestConfiguration;
import org.apache.derbyTesting.junit.XATestUtil;
@@ -86,6 +88,10 @@ public class XAMemTest
}
public static Test suite() {
- return TestConfiguration.defaultSuite(XAMemTest.class);
+ if (JDBC.vmSupportsJDBC3()) {
+ return TestConfiguration.defaultSuite(XAMemTest.class);
+ }
+
+ return new TestSuite("XAMemTest skipped - XADataSource not available");
}
}
Modified: db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java?rev=1142957&r1=1142956&r2=1142957&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java (original)
+++ db/derby/code/branches/10.7/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java Tue Jul 5 10:06:55 2011
@@ -41,6 +41,7 @@ public class _Suite extends BaseJDBCTest
suite.addTest(MultiByteClobTest.suite());
suite.addTest(RolesDependencyTest.suite());
suite.addTest(MemoryLeakFixesTest.suite());
+ suite.addTest(XAMemTest.suite());
return suite;
}
}