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:08:49 UTC
svn commit: r1142960 - in /db/derby/code/branches/10.5: ./
java/engine/org/apache/derby/jdbc/
java/testing/org/apache/derbyTesting/functionTests/tests/memory/
Author: kristwaa
Date: Tue Jul 5 10:08:49 2011
New Revision: 1142960
URL: http://svn.apache.org/viewvc?rev=1142960&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.5/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.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/jdbc/XATransactionState.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 5 10:08:49 2011
@@ -1,2 +1,2 @@
/db/derby/code/branches/10.6:942027,957000,957287,958621,962738,965351,987678,997790*,1031623,1055601,1068474,1071167
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803336,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,826263,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952237,952581,954748,955001,955634,956075,956445,956659,957260,958163,958618,959550,961892,962716,964039,964402,96
5647,966393,967201,967304,980089,980684,986689,986834,987539,989099,997325*,998170,999119,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1081455,1085078,1141924
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803336,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,826263,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952237,952581,954748,955001,955634,956075,956445,956659,957260,958163,958618,959550,961892,962716,964039,964402,96
5647,966393,967201,967304,980089,980684,986689,986834,987539,989099,997325*,998170,999119,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1081455,1085078,1136363,1138341,1141924
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/jdbc/XATransactionState.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/jdbc/XATransactionState.java?rev=1142960&r1=1142959&r2=1142960&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/jdbc/XATransactionState.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/jdbc/XATransactionState.java Tue Jul 5 10:08:49 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.5/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.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java?p2=db/derby/code/branches/10.5/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=1142960&rev=1142960&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java Tue Jul 5 10:08:49 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.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java?rev=1142960&r1=1142959&r2=1142960&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java Tue Jul 5 10:08:49 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;
}
}