5 Replies Latest reply on Jun 17, 2013 7:08 AM by jeremystone

    5.2.6: Cache is not transactional when invocationBatching is true

    ykalemi

      I'm trying to update Infinispan from 5.1.6 to 5.2.6. There is one failing test (see simplified listing below).

       

      Test:

      - opens transaction;

      - inserts value in cache;

      - throws an exception iside transaction;

      - checks, that cache doesn't contain this value;

      Test expects, Infinispan discards any changes inside this reverted transaction. But in 5.2.6 it doesn't.

       

      If I turn *invocationBatching* off -  everything is ok.

       

      Is there any problem in my configuration? Or is it a bug?

      Thanks.

       

      -----

       

      Cache configuration:

      {code:xml}

          <namedCache name="testCache">

              <invocationBatching enabled="true"/>

              <transaction transactionMode="TRANSACTIONAL"

                  useSynchronization="true"

                  transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup"/>

              <locking isolationLevel="READ_COMMITTED" />

              <eviction strategy="NONE" maxEntries="-1"/>

          </namedCache>

      {code}

       

       

      Service:

      {code}

      public class TestTransactionalCacheServiceImpl implements TestTransactionalCacheService

      {

          Cache<Object, Object> cache;

       

          @PostConstruct

          private void init()

          {

              DefaultCacheManager manager = new DefaultCacheManager("infinispan.xml");

              this.cache = manager.getCache("testCache");      

          }

       

          @Override

          @Transactional(propagation = Propagation.REQUIRED)

          public void executeWithException()

          {

              try

              {

                  cache.put("executeWithException", true);

                  throw new TransactionalCacheException();

              }

              catch (TransactionalCacheException e)

              {

                  throw e;

              }

              catch (Exception e)

              {

                  throw new RuntimeException(e.getMessage(), e);

              }

          }

       

          @Override

          @Transactional(propagation = Propagation.REQUIRED)

          public boolean exists(final String propertyName)

          {

              return cache.containsKey(propertyName) && (boolean)cache.get(propertyName);

          }

      }

      {code}

       

      Test:

      {code}

      @RunWith(SpringJUnit4ClassRunner.class)

      @ContextConfiguration

      @TransactionConfiguration(transactionManager = "txManager")

      public class TransactionCacheDbcTest

      {

          @Inject

          TestTransactionalCacheService service;

       

          @Test

          public void testWriteToCacheWithException() {

              try {

                  service.executeWithException();

              }

              catch (TransactionalCacheException e) {

              }

               Assert.assertFalse(service.exists("executeWithException"));

          }

      }

      {code}