package infinispan; import java.io.BufferedReader; import java.io.InputStreamReader; import javax.transaction.TransactionManager; import org.infinispan.AdvancedCache; import org.infinispan.Cache; import org.infinispan.manager.DefaultCacheManager; import org.infinispan.manager.EmbeddedCacheManager; public class Test { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); EmbeddedCacheManager manager = new DefaultCacheManager(Simple.class.getResourceAsStream("config.xml")); Cache cache = manager.getCache("myCustomCache"); AdvancedCache advancedCache = cache.getAdvancedCache(); TransactionManager tm = advancedCache.getTransactionManager(); tm.begin(); try { System.out.println("Before lock, press enter to continue"); reader.readLine(); advancedCache.lock("A"); System.out.println("Lock Acquired, press enter to continue"); reader.readLine(); cache.put("A", "B"); // if you comment this line the bug will not reproduce! tm.commit(); System.out.println("Commit Successful"); } catch (Exception e) { tm.rollback(); throw e; } } }