1 Reply Latest reply on Apr 28, 2018 10:55 AM by Galder Zamarreño

    getTransactionManager().commit() era

    Johan Durand-Gasselin Newbie



      I'm having a problem with Infinispan in which the data is seemingly loaded into the cache twice, but only after the cache was emptied because of the timeout. This is my code :


      try {
           if (this.cache.lock(key)) {
                cached = this.cache.get(key);
                if (cached == null) {
                     // this.cache.getLockManager().unlock(key,
                     // this.cache.getLockManager().getLock(key).getLockOwner());
                     final Object value = service.read(key);
                     this.cache.put(key, value);
                     return value;
                } else {
                     return cached;
           } else {
                throw new Exception();
      } finally {
       finally {


      From my investigation, it seems that the first time my application goes through this code, the "getTransactionManager().commit()" in the "finally" removes the data that was put in the cache through the "put" method. I've looked up transactions in Infinispan and can at least tell you that the translation locking is "PESSIMISTIC". By uncommenting the "unlock" code, I don't have that problem anymore.


      Does anyone know what's happening here?