Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 18832 invoked from network); 2 Sep 2005 04:28:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Sep 2005 04:28:18 -0000 Received: (qmail 44758 invoked by uid 500); 2 Sep 2005 04:28:16 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 44606 invoked by uid 500); 2 Sep 2005 04:28:15 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 44585 invoked by uid 99); 2 Sep 2005 04:28:15 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Sep 2005 21:28:15 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 25E98123 for ; Fri, 2 Sep 2005 06:28:14 +0200 (CEST) Message-ID: <321631767.1125635294153.JavaMail.jira@ajax.apache.org> Date: Fri, 2 Sep 2005 06:28:14 +0200 (CEST) From: "Niclas Hedhman (JIRA)" To: dev@directory.apache.org Subject: [jira] Updated: (DIR-113) Usage of NullArgumentException to precondition public methods. In-Reply-To: <1987770152.1125635052696.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DIR-113?page=all ] Niclas Hedhman updated DIR-113: ------------------------------- Attachment: (was: Main.class) > Usage of NullArgumentException to precondition public methods. > -------------------------------------------------------------- > > Key: DIR-113 > URL: http://issues.apache.org/jira/browse/DIR-113 > Project: Directory > Type: Improvement > Reporter: Niclas Hedhman > Assignee: Alex Karasulu > Priority: Minor > Attachments: Main2.java, NullArgumentException.java > > All public methods of any subsystem should check all arguments for validity. One such check is to ensure that null is not passed when not semantically supported by the method. The exception should also be meaningful, and point stronger to the caller's fault, than a NullPointerException normally indicates. > The patch to follow makes this fairly simple. > public void doSomething( String arg1, String arg2 ) > { > NullArgumentException.validate( arg1, "arg1", 1 ); > NullArgumentException.validate( arg2, "arg2", 2 ); > } > will throw an NullArgumentException (extending IllegalArgumentException) if the argument is null, with the following message; > The class org.apache.directory.SomeClass passed a null argument for the first parameter "arg1" on line 123, to the doSomething() method in class org.apache.directory.SomeOtherClass. > Furthermore, the output pattern can be modified by NullArgumentException.setPattern() which takes java.text.MessageFormat patterns. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira