db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1142958 - in /db/derby/code/branches/10.6: ./ java/engine/org/apache/derby/jdbc/ java/testing/org/apache/derbyTesting/functionTests/tests/memory/
Date Tue, 05 Jul 2011 10:07:51 GMT
Author: kristwaa
Date: Tue Jul  5 10:07:51 2011
New Revision: 1142958

URL: http://svn.apache.org/viewvc?rev=1142958&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.6/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.6/   (props changed)
    db/derby/code/branches/10.6/java/engine/org/apache/derby/jdbc/XATransactionState.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul  5 10:07:51 2011
@@ -1,3 +1,3 @@
 /db/derby/code/branches/10.7:1140196
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,966393,967201,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1028716,1030043,1033485,1033864,1035164,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1078461,1081455,1097247,1103681,1103718,1141924
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,966393,967201,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1028716,1030043,1033485,1033864,1035164,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1078461,1081455,1097247,1103681,1103718,1136363,1138341,1141924
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/jdbc/XATransactionState.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/jdbc/XATransactionState.java?rev=1142958&r1=1142957&r2=1142958&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/jdbc/XATransactionState.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/jdbc/XATransactionState.java
Tue Jul  5 10:07:51 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.6/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.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java?p2=db/derby/code/branches/10.6/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=1142958&rev=1142958&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/XAMemTest.java
Tue Jul  5 10:07:51 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.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java?rev=1142958&r1=1142957&r2=1142958&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/memory/_Suite.java
Tue Jul  5 10:07:51 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;
     }
 }



Mime
View raw message