[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - PagingManagerImpl::getPageStore

clebert.suconic@jboss.com do-not-reply at jboss.com
Thu Nov 13 15:53:42 EST 2008


This comment was added into PagingManagerImpl: 


  |    //FIXME - this is not thread safe
  |    public PagingStore getPageStore(final SimpleString storeName) throws Exception
  |    {
  |       PagingStore store = stores.get(storeName);
  |       
  |       if (store == null)
  |       {
  |          store = newStore(storeName);
  | 
  |          PagingStore oldStore = stores.putIfAbsent(storeName, store);
  | 
  |          if (oldStore != null)
  |          {
  |             store = oldStore;
  |          }
  | 
  |          store.start();
  |       }
  | 
  |       return store;
  |    }
  | 

stores is a ConcurrentHashMap, and the method is using putIfAbsent, getting the currentStore case it was already set.

I don't think we need a synchronization here, since this method is used every time page is needed.  The idea was to use the ConcurrentHashmap to avoid the synchronized block.




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

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



More information about the jboss-dev-forums mailing list