[concurrency-interest] ConcurrentHashMapV8

Doug Lea dl at cs.oswego.edu
Mon Oct 3 10:20:31 EDT 2011


On 10/03/11 10:07, √iktor Ҡlang wrote:
> TBH I think they need to be symmetrical to put(key, null), no?

In a library that was not constrained by 15 years of history
and conventions, map.put(key, null) would also most likely mean
to remove mapping. We can't do that though and still obey
java.util.Map spec. But the details of new methods are still
up for grabs.

>
>     The possibilities are:
>       1. treat it as a user error, so throw NullPointerException
>       2. treat it as a (re)mapping failure, so ignore the outcome
>       3. treat it as a removal
>
>     I originally did (2), but arguments that (1) was a safer
>     option led me to change to it in latest update. But yours
>     is another of several use cases that make (3) more
>     attractive -- on the plus side, it allows atomic removal
>     (that you could use in the above case).
>     But on the minus side it might lead to unintentional
>     atomic removal.




More information about the Concurrency-interest mailing list