[jboss-cvs] JBossAS SVN: r102075 - branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 8 13:51:59 EST 2010


Author: smarlow at redhat.com
Date: 2010-03-08 13:51:59 -0500 (Mon, 08 Mar 2010)
New Revision: 102075

Modified:
   branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java
   branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java
Log:
JBPAPP-3594 On executing readonly query, WrappedConnection.checkTransactionStatus throws exception when transaction is marked for rollback.

Modified: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java	2010-03-08 18:05:42 UTC (rev 102074)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/SecurityActions.java	2010-03-08 18:51:59 UTC (rev 102075)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
  * as indicated by the @author tags. See the copyright.txt file in the
  * distribution for a full listing of individual contributors. 
  *
@@ -42,4 +42,16 @@
             return null;
          }});
    }
+
+   static String getSystemProperty(final String name, final String defaultValue)
+   {
+      PrivilegedAction<String> action = new PrivilegedAction<String>()
+      {
+         public String run()
+         {
+            return System.getProperty(name, defaultValue);
+         }
+      };
+      return AccessController.doPrivileged(action);
+   }
 }
\ No newline at end of file

Modified: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java	2010-03-08 18:05:42 UTC (rev 102074)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/TxConnectionManager.java	2010-03-08 18:51:59 UTC (rev 102075)
@@ -54,6 +54,7 @@
 import org.jboss.tm.TxUtils;
 import org.jboss.util.NestedRuntimeException;
 
+
 /**
  * The TxConnectionManager is a JBoss ConnectionManager
  * implementation for jca adapters implementing LocalTransaction and XAResource support.
@@ -148,7 +149,33 @@
    private boolean wrapXAResource;
 
    private Boolean isSameRMOverrideValue;
-   
+
+   /**
+    * If system property "org.jboss.resource.connectionmanager.TxConnectionManager.ignoreStatusMarkedForRollback" is
+    * set to "true", checkTransactionActive() will ignore STATUS_MARKED_ROLLBACK (allowing work to continue even though
+    * the transaction will fail).
+    * Default behaviour (false) is to not allow transactional work to occur after the transaction
+    * is set to STATUS_MARKED_ROLLBACK. 
+    */
+   private static final boolean IGNORE_STATUS_MARKED_FOR_ROLLBACK;
+
+   static {
+
+      boolean value = false;
+      try {
+         String property = SecurityActions.getSystemProperty("org.jboss.resource.connectionmanager.TxConnectionManager.ignoreStatusMarkedForRollback","false");
+         value = Boolean.parseBoolean(property);
+         if (value)  // show a hint that system property was read
+               Logger.getLogger(TxConnectionManager.class).info(
+                  "TxConnectionManager will allow transaction work even if tx status = STATUS_MARKED_ROLLBACK");
+      }
+      catch(Throwable t) {
+         Logger.getLogger(TxConnectionManager.class).error("could not read system property 'org.jboss.resource.connectionmanager.TxConnectionManager.ignoreStatusMarkedForRollback'", t);
+      }
+
+      IGNORE_STATUS_MARKED_FOR_ROLLBACK = value;
+   }
+
    protected static void rethrowAsSystemException(String context, Transaction tx, Throwable t)
       throws SystemException
    {
@@ -329,7 +356,12 @@
          int status = tx.getStatus();
          // Only allow states that will actually succeed
          if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING)
-            throw new RollbackException("Transaction " + tx + " cannot proceed " + TxUtils.getStatusAsString(status));
+         {
+            if (status == Status.STATUS_MARKED_ROLLBACK && IGNORE_STATUS_MARKED_FOR_ROLLBACK)
+               ;  // allow database access even though transaction is marked to fail 
+            else
+               throw new RollbackException("Transaction " + tx + " cannot proceed " + TxUtils.getStatusAsString(status));
+         }
       }
    }
 




More information about the jboss-cvs-commits mailing list