[jboss-cvs] JBossCache/src/org/jboss/cache/transaction ...
Manik Surtani
manik at jboss.org
Wed Mar 7 09:05:54 EST 2007
User: msurtani
Date: 07/03/07 09:05:54
Modified: src/org/jboss/cache/transaction TransactionEntry.java
Log:
Thread safety issues
Revision Changes Path
1.5 +15 -4 JBossCache/src/org/jboss/cache/transaction/TransactionEntry.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransactionEntry.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/transaction/TransactionEntry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- TransactionEntry.java 6 Mar 2007 19:18:20 -0000 1.4
+++ TransactionEntry.java 7 Mar 2007 14:05:54 -0000 1.5
@@ -7,6 +7,7 @@
package org.jboss.cache.transaction;
+import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
@@ -20,11 +21,13 @@
import javax.transaction.Transaction;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* Information associated with a {@link GlobalTransaction} about the transaction state.
@@ -40,8 +43,9 @@
* </ul>
*
* @author <a href="mailto:bela at jboss.org">Bela Ban</a> Apr 14, 2003
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
+ at ThreadSafe
public class TransactionEntry
{
@@ -57,7 +61,10 @@
* List<MethodCall> of modifications ({@link MethodCall}). They will be replicated on TX commit
*/
private List<MethodCall> modification_list = new LinkedList<MethodCall>();
- private List<MethodCall> cl_mod_list = new LinkedList<MethodCall>();
+
+ // For some reason we see multiple threads accessing this list - even within the same tx. Could be due to reuse of
+ // tx identifiers in the DummyTM, which is where we see this problem.
+ private List<MethodCall> cl_mod_list = new CopyOnWriteArrayList<MethodCall>();
/**
* List<MethodCall>. List of compensating {@link org.jboss.cache.marshall.MethodCall} objects
@@ -113,12 +120,14 @@
*/
public List<MethodCall> getModifications()
{
- return modification_list;
+ // make sure this isn't modified externally
+ return Collections.unmodifiableList(modification_list);
}
public List<MethodCall> getCacheLoaderModifications()
{
- return cl_mod_list;
+ // make sure this isn't modified externally
+ return Collections.unmodifiableList(cl_mod_list);
}
/**
@@ -372,5 +381,7 @@
public List<MethodCall> getCacheListenerEvents()
{
return cacheListenerEvents;
+
}
+
}
More information about the jboss-cvs-commits
mailing list