4 Replies Latest reply on Jul 1, 2010 10:20 AM by Mircea Markus

    nullpointerexception

    fang yuan Newbie

      I guys:

           I met a problem of using infinispan. The case is when using replaceAsync API from cache ,I get a nullpointerexception . The stacks :

      java.lang.NullPointerException
               at  org.infinispan.util.concurrent.locks.containers.AbstractStripedLockContainer.hash(AbstractStripedLockContainer.java:65)
               at  org.infinispan.util.concurrent.locks.containers.AbstractStripedLockContainer.hashToIndex(AbstractStripedLockContainer.java:54)
               at  org.infinispan.util.concurrent.locks.containers.OwnableReentrantStripedLockContainer.getLock(OwnableReentrantStripedLockContainer.java:62)
               at  org.infinispan.util.concurrent.locks.containers.OwnableReentrantStripedLockContainer.ownsLock(OwnableReentrantStripedLockContainer.java:66)
               at  org.infinispan.util.concurrent.locks.LockManagerImpl.ownsLock(LockManagerImpl.java:122)
               at  org.infinispan.util.concurrent.locks.DeadlockDetectingLockManager.localVsLocalDld(DeadlockDetectingLockManager.java:94)
               at  org.infinispan.util.concurrent.locks.DeadlockDetectingLockManager.lockAndRecord(DeadlockDetectingLockManager.java:78)
               at  org.infinispan.container.EntryFactoryImpl.acquireLock(EntryFactoryImpl.java:205)
               at  org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:148)
               at  org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:106)
               at  org.infinispan.interceptors.LockingInterceptor.visitLockControlCommand(LockingInterceptor.java:146)
               at  org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:82)
               at  org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
               at  org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
               at  org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:147)
               at  org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:82)
               at  org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
               at  org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
               at  org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:147)
               at  org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:82)
               at  org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
               at  org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
               at  org.infinispan.commands.AbstractVisitor.visitLockControlCommand(AbstractVisitor.java:147)
               at  org.infinispan.commands.control.LockControlCommand.acceptVisitor(LockControlCommand.java:82)
               at  org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
               at  org.infinispan.interceptors.ImplicitEagerLockingInterceptor.lockEagerly(ImplicitEagerLockingInterceptor.java:96)
               at  org.infinispan.interceptors.ImplicitEagerLockingInterceptor.visitReplaceCommand(ImplicitEagerLockingInterceptor.java:61)
               at  org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:58)
               at  org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
               at  org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:183)
               at  org.infinispan.interceptors.TxInterceptor.visitReplaceCommand(TxInterceptor.java:142)
               at  org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:58)
               at  org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
               at  org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:48)
               at  org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:34)
               at  org.infinispan.commands.AbstractVisitor.visitReplaceCommand(AbstractVisitor.java:65)
               at  org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:58)
               at  org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:269)
               at  org.infinispan.CacheDelegate.replaceAsync(CacheDelegate.java:590)
               at  org.infinispan.CacheDelegate.replaceAsync(CacheDelegate.java:579)

       

      I have checked the source code of infinispan . The reason is the key value is null, when using null to get hash value jvm will throw a nullpointerexcetpoin. But I have check the input value from our log and infinispan's log (trace level). It seems this case will only happened in multi-thread environment. I think the problem is in lockAndRecord function of DeadlockDetectingLockManager class. lockOwnerTx.getLockIntention is null.

      I don't know the reason why intention is null and how to fix this problem . My temp solution is adding a judgement that when only intention is not null localVsLocalDld function will be called . Is that ok? And could someone help me?