Quantcast

commons lang3: NullArgumentException missing?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

commons lang3: NullArgumentException missing?

Karsten Wutzke
Hello,

I can see NullArgumentException has been removed from the lang3 API, but I don't understand why. There have been long discussions in the past why a NullArgumentException is better than using an IllegalArgumentException. Most people are using commons-lang anyway, so what's the point of removing NullArgumentException?

What if developers don't want to use IllegalArgumentException? Is is more advantageous to have these people provide their own NullArgumentException implementations? This is stupid. One of these reasons why the commons-* libs have been created was to fill the gap where the Java API has provided nothing. Now lang3 is there, too.

If people aren't interested in using NullArgumentException as provided, why don't they simply ignore it or provide their own implementations? I don't understand it.

Any comments/explanations to clear this up are welcome.

Karsten
___________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: commons lang3: NullArgumentException missing?

Jörg Schaible-3
Hi Karsten,

[hidden email] wrote:

> Hello,
>
> I can see NullArgumentException has been removed from the lang3 API, but I
> don't understand why. There have been long discussions in the past why a
> NullArgumentException is better than using an IllegalArgumentException.
> Most people are using commons-lang anyway, so what's the point of removing
> NullArgumentException?
>
> What if developers don't want to use IllegalArgumentException? Is is more
> advantageous to have these people provide their own NullArgumentException
> implementations? This is stupid. One of these reasons why the commons-*
> libs have been created was to fill the gap where the Java API has provided
> nothing. Now lang3 is there, too.
>
> If people aren't interested in using NullArgumentException as provided,
> why don't they simply ignore it or provide their own implementations? I
> don't understand it.
>
> Any comments/explanations to clear this up are welcome.

We decided to follow the JDK and throw in our sources a NullPointerException
instead. We removed it to avoid any expectation that NullArgumentException
is still in use like before.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: commons lang3: NullArgumentException missing?

Paul Benedict
In reply to this post by Karsten Wutzke
The official standard in the JDK is to throw NPE for null arguments. Since
JDK 7, they have made API available for this in
java.util.Objects#requireNonNull(). Commons is following the official
direction.
On Dec 21, 2011 10:16 AM, <[hidden email]> wrote:
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: commons lang3: NullArgumentException missing?

Karsten Wutzke
In reply to this post by Karsten Wutzke
Wow, the Java/JDK is getting dirtier and dirtier with every release. The code

 public Foo(Bar bar) {
     this.bar = Objects.requireNonNull(bar);
 }
looks really really awful to me.

IMO it's time to reimplement the JDK and throw away backward compatibility than introduce patch after patch. At least a second clean API of the JDK should be provided.

I wonder what others are thinking about this.

Karsten


-----Ursprüngliche Nachricht-----
Von: "Paul Benedict" <[hidden email]>
Gesendet: 21.12.2011 19:04:48
An: "Commons Users List" <[hidden email]>
Betreff: Re: commons lang3: NullArgumentException missing?

>The official standard in the JDK is to throw NPE for null arguments. Since
>JDK 7, they have made API available for this in
>java.util.Objects#requireNonNull(). Commons is following the official
>direction.
>On Dec 21, 2011 10:16 AM, <[hidden email]> wrote:


___________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: commons lang3: NullArgumentException missing?

Matt Benson-2
On Wed, Dec 21, 2011 at 3:41 PM, Karsten Wutzke <[hidden email]> wrote:
> Wow, the Java/JDK is getting dirtier and dirtier with every release. The code
>
>  public Foo(Bar bar) {
>     this.bar = Objects.requireNonNull(bar);
>  }
> looks really really awful to me.

As opposed to this.bar = Validate.notNull(bar) from commons-lang3? ;)

Matt

>
> IMO it's time to reimplement the JDK and throw away backward compatibility than introduce patch after patch. At least a second clean API of the JDK should be provided.
>
> I wonder what others are thinking about this.
>
> Karsten
>
>
> -----Ursprüngliche Nachricht-----
> Von: "Paul Benedict" <[hidden email]>
> Gesendet: 21.12.2011 19:04:48
> An: "Commons Users List" <[hidden email]>
> Betreff: Re: commons lang3: NullArgumentException missing?
>
>>The official standard in the JDK is to throw NPE for null arguments. Since
>>JDK 7, they have made API available for this in
>>java.util.Objects#requireNonNull(). Commons is following the official
>>direction.
>>On Dec 21, 2011 10:16 AM, <[hidden email]> wrote:
>
>
> ___________________________________________________________
> SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
> kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...