Details
-
Type:
Bug
-
Status: Resolved (View workflow)
-
Priority:
Major
-
Resolution: Fixed
-
Affects versions: 4.3.0
-
Fix versions: 4.4.0
-
Components: Core
-
Labels:None
Description
The DefaultCache implementation implements the Map interface. There are three methods that do not correctly implement this interface;
- DefaultCache#values() - the returned collection does not honour any modifications, unlike the documented implementation at https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#values--Â - the returned collection throws an UnsupportedOperationException on any attempts to modify
- DefaultCache#entrySet() - the returned set will not throw an exception on any attempt to modify it, but will not honour the modifications in the parent Map as documented at https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#entrySet--
- DefaultCache#keySet() - the returned set will not throw an exception on any attempt to modify it, but will not honour the modifications in the parent Map as documented at https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#keySet--
Note 1: The PR at https://github.com/igniterealtime/Openfire/pull/1235Â (which also references https://issues.igniterealtime.org/browse/OF-867)Â highlights an bug that has been caused by an assumption that the DefaultCache supports the Map interface.Â
Note 2: ClusteredCache from the Hazelcast plugin does the right thing - by leveraging the Hazelcast implementation.
I can see three options;
- Make the sets returned from entrySet() and keySet() read-only, and update the Javadoc for the Cache to reflect this state. Update the ClusteredCache similarly. Also double check the code base to find any incorrect use of these methods in addition to that highlighted in
OF-867 Reopened .
- Update all three methods to return a collections that align with Map documentation. NB. This is a non-trivial exercise.
- Replace the DefaultCache with a Caffeine Cache - https://github.com/ben-manes/caffeine which supports these methods as documented.
Â
Â
Attachments
Issue links
- blocks
-
OF-867 Inconsistent use of keys in groupMetaCache
-
- Reopened
-