-
-
Notifications
You must be signed in to change notification settings - Fork 650
Closed
Labels
Milestone
Description
TreeMap.get will throw a null pointer exception when trying to do a lookup on a map with nulls in the values. HashMap works as expected under the same circumstances.
void bug() {
final HashMap<String, String> hashMap = HashMap.of(
"Thisworks", "fine",
"evenwith", null);
hashMap.get("nokey"); // Option.none()
hashMap.get("Thisworks"); // Option.some("fine")
hashMap.get("evenwith"); // Option.some(null)
final TreeMap<String, String> treeMap = TreeMap.of(
"thisbreaks", "themap",
"lolhax", null);
treeMap.get("nokey"); // Option.none()
treeMap.get("thisbreaks"); // NPE
treeMap.get("lolhax"); // NPE
}
I'm using javaslang 2.0.3
Stack trace:
java.lang.NullPointerException
at javaslang.Tuple2.compareTo(Tuple2.java:80)
at javaslang.Tuple2.compareTo(Tuple2.java:96)
at javaslang.Tuple2.compareTo(Tuple2.java:28)
at javaslang.collection.RedBlackTreeModule$Node.find(RedBlackTree.java:418)
at javaslang.collection.TreeMap.get(TreeMap.java:420)