Hi, you are doing wrong.
cache = ignite.getOrCreateCache("txn test cache"); creates a new atomic cache, because you configure another cache as transactional cacheCfg.setName("cacheName"); 2017-09-21 8:44 GMT+07:00 bingili <b...@illinois.edu>: > the test.print() before test.run() will printout three nulls, which is > correct. > However, after test.run(), the print in finally block will print out: 1 2 > null, which means cache.put("test1", "1"); cache.put("test2", "2"); are > successfully written into cache, even though the exception happens. I > thought the tx.rollback() should revert back the values of "test1" and > "test2". It would expect to print out 3 nulls after tx.rollback(). > > > null > null > null > -------- > java.lang.NullPointerException > at test.IgniteTest.run(IgniteTest.java:48) > at test.IgniteTest.main(IgniteTest.java:71) > tx.rollback > 1 > 2 > null > > public void print() { > System.out.println(cache.get("test1")); > System.out.println(cache.get("test2")); > System.out.println(cache.get("test3")); > } > > public static void main(String[] args) { > IgniteTest test = new IgniteTest(); > test.print(); > System.out.println("--------"); > try { > test.run(); > } catch (Exception ex) { > > } finally { > test.print(); > } > } > > > > -- > Sent from: http://apache-ignite-users.70518.x6.nabble.com/ > -- Thanks, Alexandr Kuramshin