]
Ben Wang resolved JBCACHE-760.
------------------------------
Resolution: Done
1. Checked in both the test case and fix to 1.4.0SP2
2. Also fix it in 2.0. However, the notification event is different is 2.0 now.
TreeCacheListener in PojoCache gets nodeModify events for invalid
objects
--------------------------------------------------------------------------
Key: JBCACHE-760
URL:
http://jira.jboss.com/jira/browse/JBCACHE-760
Project: JBoss Cache
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: PojoCache
Affects Versions: 1.4.0.SP1
Reporter: Nitzan Niv
Assigned To: Ben Wang
Fix For: 1.4.0.SP2, 2.0.0
Attachments: CollectionClassHandler.java, TreeCacheAopListenerTest.java,
TreeCacheAopListenerTest.java
In PojoCache with a registered event listener, when inserting a collection (Map, List) to
the cache, the listener gets events for the creation and then the modification of the
collection object. On a nodeModify() event (with pre==false), if you call the cache's
getObject with the received fqn you get the following runtime exception (which did not
occur on 1.3.0SP2 in a similar scenario).
I believe the modification event is raised before the collection is "really"
inserted into the cache, so the fqn points to an invalid object.
java.lang.RuntimeException: TreeCacheAopDelegate._getObject(): null AOPInstance.
at
org.jboss.cache.aop.TreeCacheAopDelegate._getObjectInternal(TreeCacheAopDelegate.java:122)
at org.jboss.cache.aop.TreeCacheAopDelegate._getObject(TreeCacheAopDelegate.java:92)
at org.jboss.cache.aop.PojoCache._getObject(PojoCache.java:722)
at org.jboss.cache.aop.PojoCache.getObject(PojoCache.java:416)
at
org.jboss.cache.notifications.TreeCacheAopListenerTest$EventLog.nodeModify(TreeCacheAopListenerTest.java:268)
at org.jboss.cache.TreeCache.notifyNodeModify(TreeCache.java:5832)
at org.jboss.cache.TreeCache._put(TreeCache.java:4425)
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:324)
at org.jgroups.blocks.MethodCall.invoke(MethodCall.java:321)
at org.jboss.cache.interceptors.CallInterceptor.invoke(CallInterceptor.java:52)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at
org.jboss.cache.interceptors.PessimisticLockInterceptor.invoke(PessimisticLockInterceptor.java:80)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.UnlockInterceptor.invoke(UnlockInterceptor.java:32)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:345)
at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:156)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at
org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:157)
at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:5520)
at org.jboss.cache.TreeCache.put(TreeCache.java:3678)
at org.jboss.cache.TreeCache.put(TreeCache.java:3349)
at org.jboss.cache.aop.InternalDelegate.put(InternalDelegate.java:133)
at org.jboss.cache.aop.InternalDelegate.putAopClazz(InternalDelegate.java:273)
at
org.jboss.cache.aop.CollectionClassHandler.collectionObjectPut(CollectionClassHandler.java:115)
at org.jboss.cache.aop.TreeCacheAopDelegate._putObject(TreeCacheAopDelegate.java:213)
at org.jboss.cache.aop.PojoCache._putObject(PojoCache.java:731)
at org.jboss.cache.aop.PojoCache.putObject(PojoCache.java:462)
at org.jboss.cache.aop.PojoCache.putObject(PojoCache.java:423)
To recreate the problem I use a test case similar to TreeCacheListenerTest but with a
PojoCache. The test is:
public void testNodeCreatedAndModifiedMapEvent() throws Exception {
EventLog el = new EventLog(cache);
cache.addTreeCacheListener(el);
Map data = new HashMap();
data.put("key", "value");
cache.putObject("/hello/world", data);
...
}
and the relevant listener code:
public void nodeModify(Fqn fqn, boolean pre, boolean isLocal) {
events.add("modify "+
(pre? "about to modify " : "Modified ") +
(isLocal? "local " : "remote ") + fqn);
if(this.cache != null && !pre) {
try {
cache.getObject(fqn);
}
catch (Exception e) {
events.add(e);
e.printStackTrace(System.err);
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: