Here's the second of my patches.

The DummyTransactionManager uses a ThreadLocal to store transactions. However, 
the manager then stores a Map in the ThreadLocal, containing transactions keyed 
by Thread. Perhaps I'm missing something, but as far as I can see the Map just 
isn't needed as ThreadLocal stores values per thread itself.

Here's a patch against revision 1.14 that removes the offending code.

*** DummyTransactionManager.java.#.1.14 Thu Jan 20 14:17:51 2005
  | --- DummyTransactionManager.java    Thu Jan 20 11:32:31 2005
  | ***************
  | *** 6,13 ****
  |   import javax.naming.InitialContext;
  |   import javax.naming.NamingException;
  |   import javax.transaction.*;
  | - import java.util.HashMap;
  | - import java.util.Map;
  |   import java.util.Properties;
  |   
  |   /**
  | --- 6,11 ----
  | ***************
  | *** 20,31 ****
  |      static DummyTransactionManager instance=null;
  |      static Logger log=Logger.getLogger(DummyTransactionManager.class);
  |   
  | !    static ThreadLocal thread_local=new ThreadLocal() {
  | !       protected synchronized Object initialValue() {
  | !          Map map=new HashMap();
  | !          return java.util.Collections.synchronizedMap(map);
  | !       }
  | !    };
  |   
  |      public DummyTransactionManager() {
  |         ;
  | --- 18,24 ----
  |      static DummyTransactionManager instance=null;
  |      static Logger log=Logger.getLogger(DummyTransactionManager.class);
  |   
  | !    static ThreadLocal thread_local=new ThreadLocal();
  |   
  |      public DummyTransactionManager() {
  |         ;
  | ***************
  | *** 185,193 ****
  |       *                         unexpected way.
  |       */
  |      public Transaction getTransaction() throws SystemException {
  | !       Map map=(Map)thread_local.get();
  | !       String thread=Thread.currentThread().toString();
  | !       return (Transaction)map.get(thread);
  |      }
  |   
  |      /**
  | --- 178,184 ----
  |       *                         unexpected way.
  |       */
  |      public Transaction getTransaction() throws SystemException {
  | !       return (Transaction)thread_local.get();
  |      }
  |   
  |      /**
  | ***************
  | *** 240,253 ****
  |      }
  |   
  |      void setTransaction(Transaction tx) {
  | -       Map map=(Map)thread_local.get();
  | -       String thread=Thread.currentThread().toString();
  | - //        map.put(this, tx);
  |         if(tx == null) {
  | !          map.remove(thread);
  |         }
  |         else {
  | !          map.put(thread, tx);
  |         }
  |      }
  |   
  | --- 231,241 ----
  |      }
  |   
  |      void setTransaction(Transaction tx) {
  |         if(tx == null) {
  | !          thread_local.remove();
  |         }
  |         else {
  | !          thread_local.set(tx);
  |         }
  |      }

Tim.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3863023#3863023

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3863023


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to