You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating ImmutableSortedMap instances the documentation for methods copyOf and copyOfSorted state:
"NullPointerException - if any key or value in map is null"
However this behavior is not consistent an it is possible to create a map with null values.
Given a HashMap of stings with map:{a:null} all the copOf methods throw as expected, with a map:{a:null, b:two} then none of the copyOf methods throw.
Given a SortedMap of strings with map:{a:null} and a natural order copyOf and copyOfSorted all throw as expected; with a map:{a:null, b:two} then copyOf(Map) and copyOfSorted(SortedMap) throw; copyOf(Iterable), copyOf(Iterable, Comparator), copyOf(Map, Comparator) do not throw; with a map:{a:one, b:null} copyOf and copyOfSorted all throw as expected.
From what I can tell this behavior is only present for maps with two elements and only when the null is the first value of the first key. The of and builder methods are not effected an throw as expected.
The text was updated successfully, but these errors were encountered:
When creating
ImmutableSortedMap
instances the documentation for methodscopyOf
andcopyOfSorted
state:However this behavior is not consistent an it is possible to create a map with null values.
Given a
HashMap
of stings withmap:{a:null}
all thecopOf
methods throw as expected, with amap:{a:null, b:two}
then none of thecopyOf
methods throw.Given a
SortedMap
of strings withmap:{a:null}
and a natural ordercopyOf
andcopyOfSorted
all throw as expected; with amap:{a:null, b:two}
thencopyOf(Map)
andcopyOfSorted(SortedMap)
throw;copyOf(Iterable)
,copyOf(Iterable, Comparator)
,copyOf(Map, Comparator)
do not throw; with amap:{a:one, b:null}
copyOf
andcopyOfSorted
all throw as expected.From what I can tell this behavior is only present for maps with two elements and only when the
null
is the first value of the first key. Theof
andbuilder
methods are not effected an throw as expected.The text was updated successfully, but these errors were encountered: