5 Replies Latest reply on Nov 20, 2008 1:30 PM by Clebert Suconic

    PagingManagerImpl::getPageStore

    Clebert Suconic Master

      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 called. The idea was to use the ConcurrentHashmap to avoid the synchronized block.