[concurrency-interest] ConcurrentHashMapV8

Doug Lea dl at cs.oswego.edu
Mon Oct 3 09:52:04 EDT 2011


On 10/03/11 09:34, √iktor Ҡlang wrote:

> I'd love to be able to specify a Comparator in the constructor so that
> conditional remove doesn't rely on reference-equality or .equals (since
> oftentimes I cannot overload it)

One reasonable way to do this interacts with a decision
I keep flip-flopping on because people make good cases for
all three of the possibilities: What should the map do when
either a mapper or remapper function returns null?
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.

Further arguments welcome.

-Doug





More information about the Concurrency-interest mailing list