We're currently using JBossCache 1.2.3. When running the following test code we experienced that the last test case marked with THIS FAILS causes a problem.
public void testSimpleRollbackTransactions() throws Exception { TreeCache firstCache = new TreeCache(); firstCache.setTransactionManagerLookup(new DummyTransactionManagerLookup()); firstCache.start(); UserTransaction tx = new DummyUserTransaction(DummyTransactionManager.getInstance()); tx.begin(); firstCache.put("/testNode/node1/first", "entry", "commit"); tx.commit(); tx = new DummyUserTransaction(DummyTransactionManager.getInstance()); tx.begin(); firstCache.put("/testNode/node1/first", "entry", "rollback"); firstCache.remove("/testNode/node1/first"); tx.rollback(); assertEquals("Node should keep the commited value", "commit", firstCache.get("/testNode/node1/first").get("entry")); tx = new DummyUserTransaction(DummyTransactionManager.getInstance()); tx.begin(); firstCache.remove("/testNode/node1/first"); firstCache.put("/testNode/node1/first", "entry", "rollback"); tx.rollback(); assertEquals("Node should keep the commited value", "commit", firstCache.get("/testNode/node1/first").get("entry")); // THIS FAILS }
As a test I changed the order in the LockInterceptor for the rollback case, i.e first the temporary nodes are removed and then the list of operations is undone. This solves the above stated problem, but I don't know if it works in any cases.