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 4F4EB9F9A for ; Fri, 30 Mar 2012 03:02:01 +0000 (UTC) Received: (qmail 85233 invoked by uid 500); 30 Mar 2012 03:02:00 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 85163 invoked by uid 500); 30 Mar 2012 03:02:00 -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 85140 invoked by uid 99); 30 Mar 2012 03:01:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Mar 2012 03:01:59 +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; Fri, 30 Mar 2012 03:01:58 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 51B4D34E91C for ; Fri, 30 Mar 2012 03:01:38 +0000 (UTC) Date: Fri, 30 Mar 2012 03:01:38 +0000 (UTC) From: "SHIN HWEI TAN (Created) (JIRA)" To: issues@commons.apache.org Message-ID: <425590728.36358.1333076498390.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Created] (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 X-Virus-Checked: Checked by ClamAV on apache.org 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 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