You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2014/04/10 23:00:18 UTC
[jira] [Resolved] (COLLECTIONS-514) NullPointerException in
MapBackedSet.mapBackedSet
[ https://issues.apache.org/jira/browse/COLLECTIONS-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Neidhart resolved COLLECTIONS-514.
-----------------------------------------
Resolution: Invalid
The use TreeBag states that it uses a TreeMap as underlying data structure, this the same limitations apply as for a TreeMap.
In fact I consider this even a bug in the jdk, as the TreeMap states that adding a mapping with a null key and natural ordering will result in a NullPointerException, although it does not immediately, only when you try to get the entry with a null key:
{noformat}
SortedMap<String, String> map = new TreeMap<String, String>();
map.put(null, null);
System.out.println(map.get(null));
{noformat}
The NullPointerException is only thrown in the call to get().
> NullPointerException in MapBackedSet.mapBackedSet
> -------------------------------------------------
>
> Key: COLLECTIONS-514
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-514
> Project: Commons Collections
> Issue Type: Bug
> Components: Bag, Collection, Set
> Affects Versions: 4.0
> Environment: MacOS 10.9, Java 6
> Reporter: Cyrille Artho
> Attachments: Report2.java
>
>
> It seems that addAll has issues with adding a set that is backed by a singleton map with entry null -> null. However, the javadoc of the involved classes does not state that null entries are disallowed.
> Either the code should allow adding a null entry to a bag, or the documentation should state that null entries are not allowed.
> See the attached unit test in JUnit format to reproduce the problem.
--
This message was sent by Atlassian JIRA
(v6.2#6252)