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 2015/11/27 22:12:14 UTC
[jira] [Closed] (COLLECTIONS-555) Undefined NullPointerException in
TreeBag.java
[ https://issues.apache.org/jira/browse/COLLECTIONS-555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Neidhart closed COLLECTIONS-555.
---------------------------------------
> Undefined NullPointerException in TreeBag.java
> ----------------------------------------------
>
> Key: COLLECTIONS-555
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-555
> Project: Commons Collections
> Issue Type: Bug
> Components: Bag
> Affects Versions: 4.1
> Reporter: M Kim
> Priority: Minor
> Fix For: 4.1
>
>
> In add(final E object) method of TreeBag.java, the parameter object is not null-checked in throw IlligalArgumentException statement. Thus, it crashes with an inappropriate type of exceptions when the parameter, object is null. object can be null from the argument, transform(object) in TransformedCollection.add(final E object).
> I think object ==null should be added in the predicate of the throw IlligalArgumentException statement like below.
> {code}
> public boolean add(final E object) {
> if((object==null) || (comparator() == null && !(object instanceof Comparable))) {
> throw new IllegalArgumentException("Objects of type " + object.getClass() + " cannot be added to " +
> "a naturally ordered TreeBag as it does not implement Comparable");
> }
> return super.add(object);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)