Bug 1382273

Summary: [GSS 6.6.x] NPE in CacheNotifierImpl by LIRS eviction listener
Product: [JBoss] JBoss Data Grid 6 Reporter: Ted Jongseok Won <jwon>
Component: InfinispanAssignee: William Burns <wburns>
Status: VERIFIED --- QA Contact: Martin Gencur <mgencur>
Severity: high Docs Contact:
Priority: high    
Version: 6.4.1CC: jdg-bugs, jsenko, vjuranek, wfink
Target Milestone: DR1   
Target Release: 6.6.2   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1404373 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1374440, 1404373    
Attachments:
Description Flags
reproducer none

Description Ted Jongseok Won 2016-10-06 08:25:22 UTC
Created attachment 1207840 [details]
reproducer

Description of problem:
The EvictionListenerNPETest unit test in the attachment fails and throws NPE in CacheNotifierImpl.notifyCacheEntriesEvicted method when trying to reinsert the first keys again.
It reproduces only with LIRS eviction strategy and eviction listener.
However, LRU and UNORDERED eviction strategies are working properly.
It makes impossible the use of eviction listeners with LIRS eviction strategy.

It's able to reproduce by:
- inserting 20 keys - values in a 10 sized cache ( keys from key-1 to key-20),
- and then reinsert the first 10 keys (key-1 to key-10)


How reproducible:
mvn -Dtest=org.infinispan.EvictionListenerNPETest#testEvictionListener test

Steps to Reproduce:
1. Download and unzip the reproducer attachement infinispan-eviction-npe.zip
2. cd infinispan-eviction-npe
3. Run "mvn -Dtest=org.infinispan.EvictionListenerNPETest#testEvictionListener test"

Actual results:
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.infinispan.EvictionListenerNPETest
2016-10-06 16:57:23,858 (main) [ERROR - org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:124)] ISPN000136: Execution error
java.lang.NullPointerException
	at org.infinispan.notifications.cachelistener.CacheNotifierImpl$1$1.getKey(CacheNotifierImpl.java:340)
	at org.infinispan.commons.util.InfinispanCollections.transformCollectionToMap(InfinispanCollections.java:242)
	at org.infinispan.notifications.cachelistener.CacheNotifierImpl.notifyCacheEntriesEvicted(CacheNotifierImpl.java:333)
	at org.infinispan.eviction.EvictionManagerImpl.onEntryEviction(EvictionManagerImpl.java:144)
	at org.infinispan.container.DefaultDataContainer$DefaultEvictionListener.onEntryEviction(DefaultDataContainer.java:257)
	at org.infinispan.commons.util.concurrent.jdk8backported.BoundedEquivalentConcurrentHashMapV8.notifyEvictionListener(BoundedEquivalentConcurrentHashMapV8.java:285)
	at org.infinispan.commons.util.concurrent.jdk8backported.BoundedEquivalentConcurrentHashMapV8.get(BoundedEquivalentConcurrentHashMapV8.java:2281)
	at org.infinispan.container.DefaultDataContainer.peek(DefaultDataContainer.java:141)
	at org.infinispan.container.DefaultDataContainer.get(DefaultDataContainer.java:146)
	at org.infinispan.container.EntryFactoryImpl.getFromContainer(EntryFactoryImpl.java:266)
	at org.infinispan.container.EntryFactoryImpl.wrapEntryForPut(EntryFactoryImpl.java:193)
	at org.infinispan.interceptors.EntryWrappingInterceptor.wrapEntryForPutIfNeeded(EntryWrappingInterceptor.java:173)
	at org.infinispan.interceptors.EntryWrappingInterceptor.visitPutKeyValueCommand(EntryWrappingInterceptor.java:167)
	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:71)
	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:98)
	at org.infinispan.interceptors.locking.AbstractLockingInterceptor.visitPutKeyValueCommand(AbstractLockingInterceptor.java:48)
	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:71)
	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:98)
	at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:112)
	at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:34)
	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:71)
	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:98)
	at org.infinispan.interceptors.CacheMgmtInterceptor.updateStoreStatistics(CacheMgmtInterceptor.java:148)
	at org.infinispan.interceptors.CacheMgmtInterceptor.visitPutKeyValueCommand(CacheMgmtInterceptor.java:134)
	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:71)
	at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:98)
	at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:104)
	at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:73)
	at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:34)
	at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:71)
	at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:336)
	at org.infinispan.CacheImpl.executeCommandAndCommitIfNeeded(CacheImpl.java:1520)
	at org.infinispan.CacheImpl.putInternal(CacheImpl.java:998)
	at org.infinispan.CacheImpl.put(CacheImpl.java:990)
	at org.infinispan.CacheImpl.put(CacheImpl.java:983)
	at org.infinispan.CacheImpl.put(CacheImpl.java:250)
	at org.infinispan.EvictionListenerNPETest.testEvictionListener(EvictionListenerNPETest.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:242)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:137)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Tests in error: 
  testEvictionListener(org.infinispan.EvictionListenerNPETest)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0


Expected results: It should be passed.


Additional info: Same bug exists in infinispan upstream master. https://issues.jboss.org/browse/ISPN-7080