NPE in InvalidationInterceptor.getNodeVersion()
brian.stansberry Feb 26, 2008 7:50 PMFrom a Hibernate/JBC integration test case:
16:15:20,049 WARN InvalidationInterceptor:270 - Unable to broadcast evicts as a part of the prepare phase. Rolling back. java.lang.NullPointerException at org.jboss.cache.interceptors.InvalidationInterceptor.getNodeVersion(InvalidationInterceptor.java:347) at org.jboss.cache.interceptors.InvalidationInterceptor.invalidateAcrossCluster(InvalidationInterceptor.java:336) at org.jboss.cache.interceptors.InvalidationInterceptor.invalidateModifications(InvalidationInterceptor.java:372) at org.jboss.cache.interceptors.InvalidationInterceptor.broadcastInvalidate(InvalidationInterceptor.java:266) at org.jboss.cache.interceptors.InvalidationInterceptor.handleCommitMethod(InvalidationInterceptor.java:208) at org.jboss.cache.interceptors.MethodDispacherInterceptor.invoke(MethodDispacherInterceptor.java:117) at org.jboss.cache.interceptors.Interceptor.nextInterceptor(Interceptor.java:111) at org.jboss.cache.interceptors.NotificationInterceptor.handleCommitMethod(NotificationInterceptor.java:42) at org.jboss.cache.interceptors.MethodDispacherInterceptor.invoke(MethodDispacherInterceptor.java:117) at org.jboss.cache.interceptors.Interceptor.nextInterceptor(Interceptor.java:111) at org.jboss.cache.interceptors.TxInterceptor.handleCommitRollback(TxInterceptor.java:849) at org.jboss.cache.interceptors.TxInterceptor.runCommitPhase(TxInterceptor.java:896) at org.jboss.cache.interceptors.TxInterceptor$RemoteSynchronizationHandler.afterCompletion(TxInterceptor.java:1240) at org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler.afterCompletion(TxInterceptor.java:1404) at org.jboss.cache.interceptors.OrderedSynchronizationHandler.afterCompletion(OrderedSynchronizationHandler.java:95) at org.hibernate.test.tm.SimpleJtaTransactionImpl.commit(SimpleJtaTransactionImpl.java:95) at org.hibernate.test.tm.SimpleJtaTransactionManagerImpl.commit(SimpleJtaTransactionManagerImpl.java:85) at org.hibernate.test.cache.jbc2.functional.bulk.BulkOperationsTest.createContacts(BulkOperationsTest.java:137) at org.hibernate.test.cache.jbc2.functional.bulk.BulkOperationsTest.testBulkOperations(BulkOperationsTest.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at org.hibernate.junit.functional.FunctionalTestCase.runTest(FunctionalTestCase.java:125) at junit.framework.TestCase.runBare(TestCase.java:127) at org.hibernate.junit.UnitTestCase.runBare(UnitTestCase.java:63) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125) at org.apache.maven.surefire.Surefire.run(Surefire.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
This happens during a commit of a tx that did a bunch of put calls, plus some remove calls for nodes that didn't actually exist in the local cache.
The getNodeVersion() code that fails looks like this:
protected DataVersion getNodeVersion(TransactionWorkspace w, Fqn f) { if (w == null) return null; WorkspaceNode wn = w.getNode(f); DataVersion v = wn.getVersion(); ...
NPE in last line because wn is null.
I think the problem is because the fqn points to a node that doesn't exist in the workspace -- i.e. a nodeRemove() call was made for it, so the Fqn got associated with the tx, but no node w/ that fqn existed, so there's no node in the workspace.
I tried to write a simple unit test to demonstrate that, but it passes. ??? So, instead of a JIRA I'm opening a forum thread.
OT: the invalidation messages associated with a tx aren't batched. :-(