Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DEE6397A5 for ; Mon, 9 Apr 2012 17:29:40 +0000 (UTC) Received: (qmail 68772 invoked by uid 500); 9 Apr 2012 17:29:40 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 68634 invoked by uid 500); 9 Apr 2012 17:29:40 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 68626 invoked by uid 99); 9 Apr 2012 17:29:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Apr 2012 17:29:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Apr 2012 17:29:38 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 156F4361AD2 for ; Mon, 9 Apr 2012 17:29:17 +0000 (UTC) Date: Mon, 9 Apr 2012 17:29:17 +0000 (UTC) From: "Thomas Neidhart (Resolved) (JIRA)" To: issues@commons.apache.org Message-ID: <180357969.3532.1333992557105.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <425590728.36358.1333076498390.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (COLLECTIONS-400) Inconsistent Javadoc comment and code in addIgnoreNull(Collection, T) in org.apache.commons.collections.CollectionUtils MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COLLECTIONS-400?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Neidhart resolved COLLECTIONS-400. ----------------------------------------- Resolution: Fixed Fix Version/s: 4.0 Thanks for the report. I have added the missing null check in r1311344. > Inconsistent Javadoc comment and code in addIgnoreNull(Collection, T) in org.apache.commons.collections.CollectionUtils > -------------------------------------------------------------------------------------------------------------------------- > > Key: COLLECTIONS-400 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-400 > Project: Commons Collections > Issue Type: Bug > Components: Collection > Affects Versions: 3.2.1 > Environment: Platform independent > Reporter: SHIN HWEI TAN > Labels: javadoc > Fix For: 4.0 > > Original Estimate: 0.05h > Remaining Estimate: 0.05h > > The Javadoc comment below states that the method "throws NullPointerException if the collection is null". > /** > ..... > * @param collection the collection to add to, must not be null > * @param object the object to add, if null it will not be added > * @return true if the collection changed > * @throws NullPointerException if the collection is null > */ > public static boolean addIgnoreNull(Collection collection, T object) { > return (object != null && collection.add(object)); > } > However, when called with an null collection and a null object (i.e., "addIgnoreNull((Collection)null, null)"), the method executes normally without throwing any exception. > Suggested Fixes: > 1. Add code "if (collection == null) throw NullPointerException();" at the beginning of the method body. > or > 2. Remove "@throws NullPointerException if the collection is null" from the Javadoc. > or > 3. Change "@throws NullPointerException if the collection is null" to "@throws NullPointerException if the collection is null and the object is non-null)". -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira