{"action":"opened","issue":{"url":"https://api.github.com/repos/ehcache/ehcache3/issues/326","labels_url":"https://api.github.com/repos/ehcache/ehcache3/issues/326/labels{/name}","comments_url":"https://api.github.com/repos/ehcache/ehcache3/issues/326/comments","events_url":"https://api.github.com/repos/ehcache/ehcache3/issues/326/events","html_url":"https://github.com/ehcache/ehcache3/issues/326","id":62964075,"number":326,"title":"Review CacheEventNotificationService","user":{"login":"rishabhmonga","id":5559330,"avatar_url":"https://avatars.githubusercontent.com/u/5559330?v=3","gravatar_id":"","url":"https://api.github.com/users/rishabhmonga","html_url":"https://github.com/rishabhmonga","followers_url":"https://api.github.com/users/rishabhmonga/followers","following_url":"https://api.github.com/users/rishabhmonga/following{/other_user}","gists_url":"https://api.github.com/users/rishabhmonga/gists{/gist_id}","starred_url":"https://api.github.com/users/rishabhmonga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishabhmonga/subscriptions","organizations_url":"https://api.github.com/users/rishabhmonga/orgs","repos_url":"https://api.github.com/users/rishabhmonga/repos","events_url":"https://api.github.com/users/rishabhmonga/events{/privacy}","received_events_url":"https://api.github.com/users/rishabhmonga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-19T11:48:37Z","updated_at":"2015-03-19T11:48:37Z","closed_at":null,"body":"If multiple listeners are configured for a single cache, then unexpected behaviour is observed.\nListeners tend to throw events that they are not configured for and might not throw events even if they are configured to do so.\nSubsequently, there is a failure in the following test:\npublic void testCacheEventListenerWithMultipleListener() throws Exception {\n    Configuration configuration = new XmlConfiguration(this.getClass().getResource(\"/configs/ehcache-multipleCacheEventListener.xml\"));\n    assertThat(configuration.getCacheConfigurations().containsKey(\"bar\"), is(true));\n    final CacheManager cacheManager = CacheManagerBuilder.newCacheManager(configuration);\n    final Cache<Number, String> cache = cacheManager.getCache(\"bar\", Number.class, String.class);\n    cache.put(10, \"dog\");\n    assertThat(TestCacheEventListener.FIRED_EVENT.getType(), is(EventType.CREATED));\n    assertThat(TestSecondCacheEventListener.SECOND_LISTENER_FIRED_EVENT, is(nullValue()));\n    cache.put(10, \"cat\");\n    assertThat(TestCacheEventListener.FIRED_EVENT.getType(), is(EventType.UPDATED));\n    assertThat(TestSecondCacheEventListener.SECOND_LISTENER_FIRED_EVENT.getType(), is(EventType.UPDATED));\n    cache.remove(10);\n    assertThat(TestCacheEventListener.FIRED_EVENT.getType(), is(EventType.REMOVED));\n    assertThat(TestSecondCacheEventListener.SECOND_LISTENER_FIRED_EVENT.getType(), is(EventType.REMOVED));\n    cache.put(10, \"dog\");\n    Thread.sleep(5000);\n    cache.get(10);\n    assertThat(TestCacheEventListener.FIRED_EVENT.getType(), is(EventType.EXPIRED));\n    assertThat(TestSecondCacheEventListener.SECOND_LISTENER_FIRED_EVENT.getType(), is(EventType.EXPIRED));\n  }\n\n\nThe caches configured here are :\n\n<ehcache:config\n        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n        xmlns:ehcache='http://www.ehcache.org/v3'\n        xsi:schemaLocation=\"http://www.ehcache.org/v3 ../../../main/resources/ehcache-core.xsd\">\n\n    <ehcache:cache alias=\"bar\">\n        <ehcache:key-type>java.lang.Number</ehcache:key-type>\n        <ehcache:value-type>java.lang.String</ehcache:value-type>\n        <ehcache:expiry>\n            <ehcache:ttl unit=\"seconds\">5</ehcache:ttl>\n        </ehcache:expiry>\n        <ehcache:integration>\n            <ehcache:listener>\n                <ehcache:class>com.pany.ehcache.integration.TestCacheEventListener</ehcache:class>\n                <ehcache:eventFiringMode>SYNCHRONOUS</ehcache:eventFiringMode>\n                <ehcache:eventOrderingMode>UNORDERED</ehcache:eventOrderingMode>\n                <ehcache:eventsToFireOn>CREATED</ehcache:eventsToFireOn>\n                <ehcache:eventsToFireOn>REMOVED</ehcache:eventsToFireOn>\n                <ehcache:eventsToFireOn>EXPIRED</ehcache:eventsToFireOn>\n                <ehcache:eventsToFireOn>EVICTED</ehcache:eventsToFireOn>\n                <ehcache:eventsToFireOn>UPDATED</ehcache:eventsToFireOn>\n            </ehcache:listener>\n            <ehcache:listener>\n                <ehcache:class>com.pany.ehcache.integration.TestSecondCacheEventListener</ehcache:class>\n                <ehcache:eventFiringMode>SYNCHRONOUS</ehcache:eventFiringMode>\n                <ehcache:eventOrderingMode>UNORDERED</ehcache:eventOrderingMode>\n                <ehcache:eventsToFireOn>UPDATED</ehcache:eventsToFireOn>\n                <ehcache:eventsToFireOn>REMOVED</ehcache:eventsToFireOn>\n                <ehcache:eventsToFireOn>EXPIRED</ehcache:eventsToFireOn>\n            </ehcache:listener>\n        </ehcache:integration>\n    </ehcache:cache>\n</ehcache:config>\n\n\nand the listeners added here are the following:\n\npublic class TestCacheEventListener implements CacheEventListener<Number, String> {\n\n  public static CacheEvent<Number, String> FIRED_EVENT;\n  @Override\n  public void onEvent(CacheEvent<Number, String> event) {\n    FIRED_EVENT = event;\n  }\n}\n\n\npublic class TestSecondCacheEventListener implements CacheEventListener<Number, String> {\n\n  public static CacheEvent<Number, String> SECOND_LISTENER_FIRED_EVENT;\n  @Override\n  public void onEvent(CacheEvent<Number, String> event) {\n    SECOND_LISTENER_FIRED_EVENT = event;\n  }\n}"}}