svn commit: r560155 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r560155 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java

jonesde
Author: jonesde
Date: Fri Jul 27 01:56:17 2007
New Revision: 560155

URL: http://svn.apache.org/viewvc?view=rev&rev=560155
Log:
Changed to not warn about transaction timeout if not timeout is passed to this object

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java?view=diff&rev=560155&r1=560154&r2=560155
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java Fri Jul 27 01:56:17 2007
@@ -34,7 +34,8 @@
 
     protected Transaction trans = null;
     protected boolean active = false;
-    protected int timeout = 30;
+    /** timeout is an Integer and defaults to null so that we know if it is set on this object; if it isn't set we won't worry about the warning message, etc because we don't know what the real timeout is */
+    protected Integer timeout = null;
     protected Xid xid = null;
 
     /**
@@ -144,7 +145,7 @@
      * @see javax.transaction.xa.XAResource#getTransactionTimeout()
      */
     public int getTransactionTimeout() throws XAException {
-        return this.timeout;
+        return this.timeout == null ? 0 : this.timeout.intValue();
     }
 
     /**
@@ -152,7 +153,7 @@
      * Note: the valus is saved but in the current implementation this is not used.
      */
     public boolean setTransactionTimeout(int seconds) throws XAException {
-        this.timeout = seconds == 0 ? 30 : seconds;
+        this.timeout = (seconds == 0 ? null : new Integer(seconds));
         return true;
     }
 
@@ -187,26 +188,28 @@
     // thread run method
     public void run() {
         try {
-            // sleep until the transaction times out
-            sleep(timeout * 1000);
-
-            if (active) {
-                // get the current status
-                int status = Status.STATUS_UNKNOWN;
-                if (trans != null) {
-                    try {
-                        status = trans.getStatus();
-                    } catch (SystemException e) {
-                        Debug.logWarning(e, module);
+            if (timeout != null) {
+                // sleep until the transaction times out
+                sleep(timeout.intValue() * 1000);
+
+                if (active) {
+                    // get the current status
+                    int status = Status.STATUS_UNKNOWN;
+                    if (trans != null) {
+                        try {
+                            status = trans.getStatus();
+                        } catch (SystemException e) {
+                            Debug.logWarning(e, module);
+                        }
                     }
-                }
 
-                // log a warning message
-                String statusString = TransactionUtil.getTransactionStateString(status);
-                Debug.logWarning("Transaction timeout [" + timeout + "] Status: " + statusString + " Xid: " + getXid(), module);
+                    // log a warning message
+                    String statusString = TransactionUtil.getTransactionStateString(status);
+                    Debug.logWarning("Transaction timeout [" + timeout + "] Status: " + statusString + " Xid: " + getXid(), module);
 
-                // run the abstract method
-                runOnTimeout();
+                    // run the abstract method
+                    runOnTimeout();
+                }
             }
         } catch (InterruptedException e) {
             Debug.logWarning(e, "InterruptedException thrown", module);