[infinispan-issues] [JBoss JIRA] (ISPN-7820) Uncommitted functional command modifies value

Radim Vansa (JIRA) issues at jboss.org
Tue May 9 18:06:00 EDT 2017


     [ https://issues.jboss.org/browse/ISPN-7820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Radim Vansa updated ISPN-7820:
------------------------------
    Description: 
In transactional mode, functional read write command loads the value into the context without making a defensive copy. Then, the function is applied directly on that value, exposing uncommitted changes to all other threads. Rollback is ineffective, the value is already changed.

There are no tests for rollback in FunctionalTxInMemoryTest.

Reproducer:
{code:java}
   @Test
   public void testValueInContextIsACopy() throws Exception {
      Object key = getKeyForCache(cache(0, DIST), cache(1, DIST));
      cache(0, DIST).put(key, new ArrayList());

      tm.begin();
      // nasty cast
      FunctionalMap.ReadWriteMap<Object, List> otherRw = (FunctionalMap.ReadWriteMap) rw;
      otherRw.eval(key, (Serializable & Function<EntryView.ReadWriteEntryView<Object, List>, Object>) view -> {
         List list = view.get();
         list.add("woohoo");
         view.set(list);
         return null;
      }).join();
      tm.rollback();

      assertEquals(new ArrayList(), cache(0, DIST).get(key));
   }
{code}

  was:
In transactional mode, functional read write command loads the value into the context without making a defensive copy. Then, the function is applied directly on that value, exposing uncommitted changes to all other threads. Rollback is ineffective, the value is already changed.

There are no tests for rollback in FunctionalTxInMemoryTest.



> Uncommitted functional command modifies value
> ---------------------------------------------
>
>                 Key: ISPN-7820
>                 URL: https://issues.jboss.org/browse/ISPN-7820
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Core, Test Suite - Core, Transactions
>    Affects Versions: 9.0.0.Final
>            Reporter: Radim Vansa
>            Assignee: Radim Vansa
>
> In transactional mode, functional read write command loads the value into the context without making a defensive copy. Then, the function is applied directly on that value, exposing uncommitted changes to all other threads. Rollback is ineffective, the value is already changed.
> There are no tests for rollback in FunctionalTxInMemoryTest.
> Reproducer:
> {code:java}
>    @Test
>    public void testValueInContextIsACopy() throws Exception {
>       Object key = getKeyForCache(cache(0, DIST), cache(1, DIST));
>       cache(0, DIST).put(key, new ArrayList());
>       tm.begin();
>       // nasty cast
>       FunctionalMap.ReadWriteMap<Object, List> otherRw = (FunctionalMap.ReadWriteMap) rw;
>       otherRw.eval(key, (Serializable & Function<EntryView.ReadWriteEntryView<Object, List>, Object>) view -> {
>          List list = view.get();
>          list.add("woohoo");
>          view.set(list);
>          return null;
>       }).join();
>       tm.rollback();
>       assertEquals(new ArrayList(), cache(0, DIST).get(key));
>    }
> {code}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the infinispan-issues mailing list