[jboss-cvs] JBossAS SVN: r77844 - branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/tm/usertx/client.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 3 10:27:38 EDT 2008
Author: galder.zamarreno at jboss.com
Date: 2008-09-03 10:27:38 -0400 (Wed, 03 Sep 2008)
New Revision: 77844
Modified:
branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/tm/usertx/client/ClientUserTransaction.java
Log:
[JBPAPP-1157] ClientUserTransaction singleton initialisation is not thread safe. Added some trace logging in case anyone needs them when debugging this area.
Modified: branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/tm/usertx/client/ClientUserTransaction.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/tm/usertx/client/ClientUserTransaction.java 2008-09-03 14:26:01 UTC (rev 77843)
+++ branches/JBPAPP_4_2_0_GA_CP/server/src/main/org/jboss/tm/usertx/client/ClientUserTransaction.java 2008-09-03 14:27:38 UTC (rev 77844)
@@ -46,6 +46,8 @@
import org.jboss.tm.usertx.interfaces.UserTransactionSession;
import org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory;
+import org.jboss.util.Strings;
+import org.jboss.logging.Logger;
import org.jboss.naming.NamingContextFactory;
/**
@@ -60,6 +62,7 @@
* here.
* @author <a href="mailto:osh at sparre.dk">Ole Husgaard</a>
* @author Scott.Stark at jboss.org
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public class ClientUserTransaction
@@ -75,15 +78,19 @@
/**
* Our singleton instance.
*/
- private static ClientUserTransaction singleton = null;
+ private static ClientUserTransaction singleton = new ClientUserTransaction();
+
+ private static final Logger log = Logger.getLogger(ClientUserTransaction.class);
+ private static boolean trace = log.isTraceEnabled();
+
/**
* Return a reference to the singleton instance.
+ *
+ * @return the singleton
*/
public static ClientUserTransaction getSingleton()
{
- if (singleton == null)
- singleton = new ClientUserTransaction();
return singleton;
}
@@ -397,6 +404,12 @@
ret = new ThreadInfo();
threadInfo.set(ret);
}
+
+ if (trace)
+ {
+ log.trace("Thread local: " + threadInfo);
+ log.trace("Thread info holder: " + ret);
+ }
return ret;
}
@@ -430,13 +443,17 @@
protected void finalize()
throws Throwable
{
+ if (trace)
+ {
+ log.trace("Tpc stack: finalize " + this);
+ }
+
try
{
while (!tpcStack.isEmpty())
{
Object tpc = getTpc();
pop();
-
try
{
getSession().rollback(tpc);
@@ -460,6 +477,11 @@
void push(Object tpc)
{
tpcStack.addLast(tpc);
+ trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction
+ if (trace)
+ {
+ log.trace("Tpc stack: added " + this + " tpc=" + tpc);
+ }
}
/**
@@ -467,7 +489,11 @@
*/
void pop()
{
- tpcStack.removeLast();
+ Object tpc = tpcStack.removeLast();
+ if (trace)
+ {
+ log.trace("Tpc stack: removed " + this + " tpc=" + tpc);
+ }
}
/**
@@ -475,7 +501,12 @@
*/
Object getTpc()
{
- return (tpcStack.isEmpty()) ? null : tpcStack.getLast();
+ Object tpc = (tpcStack.isEmpty()) ? null : tpcStack.getLast();
+ if (trace)
+ {
+ log.trace("Tpc stack: peek " + this + " tpc=" + tpc);
+ }
+ return tpc;
}
/**
More information about the jboss-cvs-commits
mailing list