Hi Thiago,
2014-05-06 14:53 GMT+02:00 Thiago Andrade <thia...@gmail.com>: > Hello people, > > Analizing the JIRA issue https://issues.apache.org/jira/browse/LANG-1008the > contributors noticed that NumberUtils.max/min methods all have the same > problem: > They all throw an IllegalArgumentException when according to the official > documentation (Oracle|Sun) says that a NullPointerException must be thrown > when an argument must not be null. > This is not a problem imho. It is a question of API design. I don't now an offical documentation that say when IAE or NPE _must_ be thrown. Sun/Oracle at some point decided to throw NPE when ever a null reference is passed to a method that doesn't accept null inputs. I don't feel this is right, since a null input is also an illegal argument. Why make a differenciation? IMHO NPE should be reserved to the JVM, when a method is called on a null reference, but that's just my opinion. > > However according to Apache Commons Lang Developer Guide, these methods are > all correct. This guide says that "When throwing an exception to indicate a > bad argument, always try to throw IllegalArgumentException, even if the > argument was null. Do not throw NullPointerException.". > Since [lang] is currently designed this way, I'd rather deal with this issue for 4.0. We can then revisit our initial decision to only throw IAE an maybe align it to what the JDK now does. If you want to file an issue, my opinion is, that it should be fix version 4.0. Changing the exceptions that are thrown now may break clients (although I think there are very few use cases where one should catch IAE or NPE). > > This mail was sent in order to discuss around and make decisions to solve > this dilemma where the Java official specification says X and the Apache > official specification says Y. > Can you please provide a lnk to the official specification you're refering to? ;-) Regards, Benedikt > > My sincere thanks for your time and consideration, > > -- > Thiago Andrade > -- http://people.apache.org/~britter/ http://www.systemoutprintln.de/ http://twitter.com/BenediktRitter http://github.com/britter