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

A listener which receives CacheEntryCreatedEvent + CacheEntryModifiedEvent events always has a null value after a Cache.put while a Cache.put which replaces delivers the actual value.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 4.2.0.CR3
    • Listeners
    • None

    Description

      It would be advantageous if the beheaviour of the delivered modify events did not deliver null values after a put which is different from a put which replaces which does deliver the actual value. It is also not possible to take the key from the create event and try and read the cache. I have tried printing both when the Event.isPre() field is false and true and the value is null.

      Please examine the provided test harness which includes some prints the output which demonstrates the problem...

      package miroslav.pokorny.cache.infinispan;

      import org.infinispan.manager.DefaultCacheManager;
      import org.infinispan.manager.EmbeddedCacheManager;
      import org.infinispan.notifications.Listener;
      import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
      import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
      import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent;
      import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;

      public class InfinispanValueProblemTest {

      private final static String KEY = "key";
      private final static String VALUE = "Value";

      static public void main(final String[] ignored)

      { final EmbeddedCacheManager manager = new DefaultCacheManager(); final org.infinispan.Cache<String, String> cache = manager.getCache(); cache.addListener(new InfinispanCacheListener()); cache.put(KEY, VALUE); }

      @Listener
      static final public class InfinispanCacheListener {

      @CacheEntryCreated
      public void entryCreated(final CacheEntryCreatedEvent<String, String> event)

      { System.out.println("CREATE EVENT\n\t" + event.getKey() + "= cant do get value\n\tisPre=" + event.isPre() + "\n\tevent.getCache().get(event.getKey())=" + event.getCache().get(event.getKey())); }

      @CacheEntryModified
      public void entryModified(final CacheEntryModifiedEvent<String, String> event)

      { System.out.println("MODIFIED EVENT\n\t" + event.getKey() + "=" + event.getValue() + "\n\tisPre=" + event.isPre() + "\n\tevent.getCache().get(event.getKey())=" + event.getCache().get(event.getKey())); }

      }
      }

      -------------------------------------------

      Running the test should print something like this

      [ GlobalComponentRegistry] - Infinispan version: Infinispan 'Ursus' 4.2.0.CR3
      [ ComponentRegistry] - Infinispan version: Infinispan 'Ursus' 4.2.0.CR3
      CREATE EVENT
      key= cant do get value
      isPre=true
      event.getCache().get(event.getKey())=null
      CREATE EVENT
      key= cant do get value
      isPre=false
      event.getCache().get(event.getKey())=null
      MODIFIED EVENT
      key=null
      isPre=true
      event.getCache().get(event.getKey())=null
      MODIFIED EVENT
      key=Value
      isPre=false
      event.getCache().get(event.getKey())=null

      Attachments

        Issue Links

          Activity

            People

              manik_jira Manik Surtani (Inactive)
              mpokorny_jira Miroslav Pokorny (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: