EHC ❯ NPE when getting from an in-memory cache with statistics enabled
-
Bug
-
Status: Open
-
3 Minor
-
Resolution:
-
ehcache-core
-
-
cdennis
-
Reporter: philtom
-
January 27, 2011
-
0
-
Watchers: 1
-
October 11, 2011
-
Attachments
Description
When using an in-memory cache with statistics enabled, getting from the cache with a null key will throw a NullPointerException. Example code is attached.
Comments
Fiona OShea 2011-01-31
Chris Dennis 2011-02-01
The behavior difference he is refering to is that when doing cache.get(null) without stats enabled it returns null (it always misses). When you enable statistics it takes a different code path, and ends up throwing a NullPointerException. This difference is because without stats we call store.get(key), with stats we call store.containsKey(key) first, the latter one of these throws.
Do you want me to just fix this in trunk (seems like the best option to me), or should I also merge to the Fremantle RC branch too?
Chris Dennis 2011-02-14
Although this is a bug (we should behave the same with both stats enabled and disabled), since we don’t support storing values against null keys I don’t consider the bug a hugely high priority, therefore I’m going to push this out in to Ulloa and downgrade it from a P1 to a P3
do we even support Null Keys?