0 Replies Latest reply on Jun 12, 2006 3:38 PM by genman

    Null keys and values in maps

    genman


      From a thread from a mailing list

      http://altair.cs.oswego.edu/mailman/private/concurrency-interest/2006-May/002486.html


      Joshua Bloch josh at bloch.us
      Fri May 12 12:22:06 EDT 2006
      |concurrency-interest| Handling Null Values in ConcurrentHashMap

      Doug,

      On 5/12/06, Doug Lea <dl at cs.oswego.edu> wrote:

      > Further digressing: I personally think that allowing
      > nulls in Maps (also Sets) is an open invitation for programs
      > to contain errors that remain undetected until
      > they break at just the wrong time. (Whether to allow nulls even
      > in non-concurrent Maps/Sets is one of the few design issues surrounding
      > Collections that Josh Bloch and I have long disagreed about.)

      I have moved towards your position over the years. It was probably a
      mistake to allow null keys in Maps and null elements in Sets. I'm
      still not sure about Map values and List elements.

      In other words, Doug hates null more than I do, but over the years
      I've come to see it as quite troublesome.

      Josh


      I'm not trying to pass on more troublesome suggestions :-) but "null" in caches sucks to have to write for, and it'd be good to be rid of them. Or at least some of them.