Is-it standard to ignore null values?
nfilotto Jul 6, 2010 7:05 AMHi All,
During my investigation, I noticed that Infinispan ignores null values. Maybe I misunderstand the contract of a Map but I thought that if a map implementation doesn't support a null value, it is supposed to throw a NullPointerException otherwise it is supposed to take into account the null value. In case of inifinispan it seems to ignore it which cans be dangerous when we first put a non null value then we try to put a null value, so we believe that the current value is null but in fact it is still the non null value. If it is forbidden we expect a NullPointerException otherwise cache.get should return null, do you agree with my assumption?
I tried the following code with the most common implementations of a Map such as HashMap, ConcurrentHashMap, LinkedHashMap, Properties and WeakHashMap and for all of them the test case described below pass:
{code}
{code}
The same test case fails with infinispan since null values are ignored. I attached the full Test Case.
Thank you for your answers,
BR,
Nicolas
-
TestNullValue.java.zip 896 bytes