History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-284
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Lars Torunski
Reporter: David Turanski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OSCache

Cache.dispatchCacheEntryEvent and Cache.addEventListener implementations are inconsistent

Created: 26/Feb/07 01:57 PM   Updated: 19/Mar/07 05:53 PM
Component/s: Base Classes
Affects Version/s: 2.2 final
Fix Version/s: 2.4


 Description  « Hide
Create a CacheEntryEventListener and register with:

class MyEntryEventListener implements CacheEntryEventListener{
      ...
    }
    MyEntryEventListener listener = new MyEntryEventListener();

// This call succeeds because CacheEventListener.isAssignableFrom(listener.getClass())
  
cacheAdmin.getCache().addCacheEventListener(listener, listener.getClass());
 -------------------------
This listener is never invoked because Cache.dispatchCacheEntryEvent has a guard condition:
if (listener[i]==CacheEntryEventListener.class){
   // notify next object in the list
}

This is incorrect it should use isAssignableFrom() or better yet, remove altogether. It is not needed since addCacheEventListener(listener, listener.getClass()); already does the validation.

Note that it would also be better to deprecate addCacheEventListener(CacheEventListener listener, Class clazz); and replace with
addCacheEventListener(CacheEventListener listener); Why do you need to pass the class as a parameter (except to work around this bug)?

The class should be determined using listener.getClass();

 All   Comments   Change History      Sort Order:
Lars Torunski - [26/Feb/07 02:41 PM ]
reviewing the report...

Lars Torunski - [15/Mar/07 04:49 PM ]
With addCacheEventListener you can add CacheEventListener objects. The method dispatchCacheEntryEvent is checking if the listener is an instance of CacheEntryEventListener and _not_ CacheEventListener. The difference is that CacheEntryEventListener extends CacheEventListener.

In my opinion e.g. dispatchCacheEntryEvent should check if listeners[i] isInstance of CacheEntryEventListener and then type casting the object.

Currently you have to call: cacheAdmin.getCache().addCacheEventListener(new MyEntryEventListener(), CacheEntryEventListener.class);