[infinispan-issues] [JBoss JIRA] (ISPN-4095) Flag.SKIP_LISTENER_NOTIFICATION does not work for CacheEntryModifiedEvent and CacheEntryCreatedEvent

tina tian (JIRA) issues at jboss.org
Wed Mar 12 00:13:10 EDT 2014


tina tian created ISPN-4095:
-------------------------------

             Summary: Flag.SKIP_LISTENER_NOTIFICATION does not work for CacheEntryModifiedEvent and CacheEntryCreatedEvent
                 Key: ISPN-4095
                 URL: https://issues.jboss.org/browse/ISPN-4095
             Project: Infinispan
          Issue Type: Bug
          Components: Listeners
            Reporter: tina tian
            Assignee: Dan Berindei


When setting Flag.SKIP_LISTENER_NOTIFICATION, listener still can be invoked when new entry is created or entry is modified.

I check the change log and found it should be caused by logic in CacheNotifierImpl, it did not check the flag on createEntry and modifyEntry event.

You can reproduce it by the code below:
public class TestInfinispan {
	
	public static void main(String[] args) {
		Cache<String, String> testCache = new DefaultCacheManager().getCache();
	
		testCache.addListener(new TestListener());
		
		AdvancedCache<String, String> advancedCache = testCache.getAdvancedCache();
		
		advancedCache = advancedCache.withFlags(Flag.SKIP_LISTENER_NOTIFICATION);

		advancedCache.put("key1", "value1");
		advancedCache.replace("key1", "value2");
	}

	@Listener
	private static class TestListener {

		@CacheEntryModified
		public void cacheEntryModified(CacheEntryModifiedEvent event) {
			System.out.println(
				"######## modify event with key " + event.getKey() + " and value " + event.getValue() );
		}

		@CacheEntryCreated
		public void cacheEntryCreated(CacheEntryCreatedEvent event) {
			System.out.println(
				"######## create event with key " + event.getKey() + " and value " + event.getValue() );
		}
	}
}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list