Apache Directory Project - [jira] Resolved: (DIR-113) Usage of NullArgumentException to

This is Interesting: Free IT Magazines  
Home > Archive > Apache Directory Project > March 2007 > [jira] Resolved: (DIR-113) Usage of NullArgumentException to





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [jira] Resolved: (DIR-113) Usage of NullArgumentException to
Emmanuel Lecharny (JIRA)

2007-03-28, 1:11 pm


[ https://issues.apache.org/jira/brow...ls:all-tabpanel ]

Emmanuel Lecharny resolved DIR-113.
-----------------------------------

Resolution: Fixed

The best ould be to use assert instead of a specific piece of code. This is what assert are for.

> Usage of NullArgumentException to precondition public methods.
> --------------------------------------------------------------
>
> Key: DIR-113
> URL: https://issues.apache.org/jira/browse/DIR-113
> Project: Directory
> Issue Type: Improvement
> Reporter: Niclas Hedhman
> Assigned To: Alex Karasulu
> Priority: Minor
> Attachments: Main.java, 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 f

ault, 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.
-
You can reply to this email to add a comment to the issue online.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com