kucci / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Equivalences.nullAwareEquals().hash(null) should return 0 rather than throw a NullPointerException #411

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was pretty surprised to discover that 
Equivalences.nullAwareEquals().hash(null) throws an NPE (by design). If it is 
"null aware," why doesn't it just return 0?

Because of this, Equivalence did not add much value when I had to implement my 
own Pair class:

http://code.google.com/p/plovr/source/browse/src/org/plovr/util/Pair.java

Though of course, if 
http://code.google.com/p/guava-libraries/issues/detail?id=203 were fixed, then 
this would have been less of an issue for me!

Original issue reported on code.google.com by bolinf...@gmail.com on 5 Sep 2010 at 3:07

GoogleCodeExporter commented 9 years ago
Not really relevant to the actual request, but isn't what you really want to 
use in your Pair class just Objects.equal and Objects.hashCode?

Original comment by cgdec...@gmail.com on 6 Sep 2010 at 12:28

GoogleCodeExporter commented 9 years ago
Thanks, I forgot about that API! Updated Pair.java and the corresponding unit 
test.

Original comment by bolinf...@gmail.com on 6 Sep 2010 at 12:52

GoogleCodeExporter commented 9 years ago
I agree (original issue). I knew it seemed wrong at the time, but for some 
reason didn't get it fixed.

Original comment by kevinb@google.com on 8 Sep 2010 at 5:58

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 8 Sep 2010 at 5:59

GoogleCodeExporter commented 9 years ago

Original comment by kurt.kluever on 8 Sep 2010 at 10:17

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 14 Sep 2010 at 3:15

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 18 Jan 2011 at 8:38

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 24 Jan 2011 at 9:34

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09