directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niclas Hedhman (JIRA)" <>
Subject [jira] Updated: (DIR-113) Usage of NullArgumentException to precondition public methods.
Date Fri, 02 Sep 2005 04:30:13 GMT
     [ ]

Niclas Hedhman updated DIR-113:


And correct file would be good...

> Usage of NullArgumentException to precondition public methods.
> --------------------------------------------------------------
>          Key: DIR-113
>          URL:
>      Project: Directory
>         Type: Improvement
>     Reporter: Niclas Hedhman
>     Assignee: Alex Karasulu
>     Priority: Minor
>  Attachments:,,
> 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 passed a null argument for the first parameter
"arg1" on line 123, to the doSomething() method in class
> 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:
For more information on JIRA, see:

View raw message