map and null values
dl at cs.oswego.edu
Thu Jan 3 09:18:26 PST 2013
On 01/03/13 11:50, Remi Forax wrote:
> I was thinking the consensus was concurrent collections and new
> collection (since 1.5) doesn't accept null,
> because older still allow null streams has to tolerate null element.
Not that it matters, but the actual history is weirder.
Initially, the only map was Hashtable, which is extremely
null-hostile (you get NPE if you even ask if it contains null).
When designing the CollectionsMap APIs, a contingent argued for
HashMap to allow nulls. (And I couldn't stop them!)
However, when ConcurrentHashMap was introduced, one of the
goals was to allow full interoperability with Hashtable
(except for not being able to lock the whole map), for which its
null-intolerance was essential to provide atomicity guarantees.
More information about the lambda-dev