Skip to content

Commit

Permalink
ISPN-5797 NullPointerException in ClientListenerRegistry under load
Browse files Browse the repository at this point in the history
* Made sure null value and metadata are supported
  • Loading branch information
wburns committed Oct 7, 2015
1 parent 3cbc384 commit b2fa70f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.event;

import org.infinispan.Cache;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.event.CustomEventLogListener.CustomEvent;
import org.infinispan.client.hotrod.event.CustomEventLogListener.FilterConverterFactory;
Expand All @@ -14,6 +15,7 @@
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.notifications.cachelistener.CacheNotifier;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder;
import org.infinispan.test.TestingUtil;
Expand Down Expand Up @@ -161,4 +163,20 @@ public void call() {
}
});
}

public void testNullValueMetadataExpiration() {
final Integer key = HotRodClientTestingUtil.getIntKeyForServer(server(0));
final EventLogListener<Integer> eventListener = new EventLogListener<>();
withClientListener(eventListener, new RemoteCacheManagerCallable(client(0)) {
@Override
public void call() {
Cache<Integer, String> cache0 = cache(0);
CacheNotifier notifier = cache0.getAdvancedCache().getComponentRegistry().getComponent(CacheNotifier.class);
byte[] keyBytes = HotRodClientTestingUtil.toBytes(key);
// Note we are manually forcing an expiration event with a null value and metadata
notifier.notifyCacheEntryExpired(keyBytes, null, null, null);
eventListener.expectOnlyExpiredEvent(key, cache(0));
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ class ClientListenerRegistry(configuration: HotRodServerConfiguration) extends L
@CacheEntryExpired
def onCacheEvent(event: CacheEntryEvent[Bytes, Bytes]) {
if (isSendEvent(event)) {
val dataVersion = event.getMetadata.version().asInstanceOf[NumericVersion].getVersion
sendEvent(event.getKey, event.getValue, dataVersion, event)
sendEvent(event.getKey, event.getValue, Option(event.getMetadata)
.map(_.version().asInstanceOf[NumericVersion].getVersion)
.getOrElse(null.asInstanceOf[Long]), event)

}
}

Expand Down

0 comments on commit b2fa70f

Please sign in to comment.