-
Notifications
You must be signed in to change notification settings - Fork 166
Description
Observations from Joe Fialli on CacheEntryEvent following the resolution of #362 :
Here is the change that I noticed inconsistencies in.
public abstract class CacheEntryEvent<K, V> extends EventObject
implements Cache.Entry<K, V>
<deleted>
/**
* Returns the value stored in the cache when this entry was created.
* <p>
* The value will be available
* for {@link CacheEntryCreatedListener}, {@link CacheEntryExpiredListener}
* and {@link CacheEntryRemovedListener}
* if {@link CacheEntryListenerConfiguration#isOldValueRequired()} is true.
*
* @return the value corresponding to this entry
*/
public abstract V getValue();
Comments on current changes:
-
Since
getValuemethod is overriding a method defined inCache.Entry, an@Overrideannotation is missing. -
getValue()is defined for{@link CacheEntryUpdateListener}, but that is not listed. Is the intent that getValue() always has a value for allCacheEntryUpdateListener, but its value being set for all other Listeners is based onCacheEntryListenerConfiguration#isOldValueRequired()being true?(2a). If answer to 2 is yes, I definitely agree that previous value for entry is not returned in
CacheEntryExpiredListenerandCacheEntryRemovedListenerwhenisOldValueRequiredis false. However,getValue()should always return entry's current value forCacheEntryCreatedListenerregardless ofCacheEntryListenerConfiguration.isOldValueRequired() -
Current solution contradicts terminology for an existing Cache API remove method
/**- Atomically removes the mapping for a key only if currently mapped to the
- given value.
.... - @param key key whose mapping is to be removed from the cache
- @param oldValue value expected to be associated with the specified key
*/
boolean javax.cache.Cache.remove(K key, V oldValue).
In this existing method, the documentation refers to the value as
oldValue(when it should for all intents be just "value"). This is a condition for the operation to occur. So the above parameter definitely should be "value" just as in a "Removed" or "Expired" Listener, the value should be considered the previous or "oldValue" prior to the entry no longer being associated with the cache. -
The undocumented exception UnsupportedOperationExceotion that is thrown by the RI but not documented in spec or javadoc. This issue was raised in issue and not addressed before it was closed.