Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-7820

Document store-by-reference effects in functional commands

    XMLWordPrintable

Details

    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:

         @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));
         }
      

      Attachments

        Activity

          People

            rvansa1@redhat.com Radim Vansa (Inactive)
            rvansa1@redhat.com Radim Vansa (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: