[infinispan-issues] [JBoss JIRA] (ISPN-5482) JSR-107 - Provide mechanism to handle expiration events

Matej Čimbora (JIRA) issues at jboss.org
Tue May 19 10:47:19 EDT 2015


Matej Čimbora created ISPN-5482:
-----------------------------------

             Summary: JSR-107 - Provide mechanism to handle expiration events 
                 Key: ISPN-5482
                 URL: https://issues.jboss.org/browse/ISPN-5482
             Project: Infinispan
          Issue Type: Feature Request
          Components: JCache
            Reporter: Matej Čimbora


Currently, expiration events are supported only by embedded mode & additionally require entry to be accessed in order to be created. This can lead to CacheEntryExpiredListener not being notified when an entry expires.

Note: Not covered by TCK tests.

Example:
{code}
   @Test
   public void testExpiration(Method m) {
      Cache<String, String> cache1 = getCache1(m);
      Cache<String, String> cache2 = getCache2(m);

      TestExpiredListener listener = new TestExpiredListener();
      MutableCacheEntryListenerConfiguration conf1 = new MutableCacheEntryListenerConfiguration(FactoryBuilder.factoryOf(listener), null, false, false);
      cache1.registerCacheEntryListener(conf1);
      cache2.put("key1", "val1");
      sleep(5000);
      // Required by embedded JCache implementation to work 
      assert cache1.get("key1") == null;
      // Failing for remote JCache implementation
      assertEquals(1, listener.invocationCount);
   }

   private static class TestExpiredListener implements CacheEntryExpiredListener, Serializable {

      private int invocationCount;

      @Override
      public void onExpired(Iterable iterable) throws CacheEntryListenerException {
         Iterator iterator = iterable.iterator();
         while (iterator.hasNext()) {
            iterator.next();
            invocationCount++;
         }
      }
   }
{code}





--
This message was sent by Atlassian JIRA
(v6.3.15#6346)



More information about the infinispan-issues mailing list