commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r899929 - in /commons/proper/lang/trunk: src/main/java/org/apache/commons/lang3/ArrayUtils.java src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java xdocs/changes.xml
Date Sat, 16 Jan 2010 20:13:22 GMT
On 16/01/2010, Henri Yandell <flamefew@gmail.com> wrote:
> Alternatively... should add(null, null) simply return null?

IMO it's a program bug to call it with both arguments null.

The caller is going to have to check for null return in order to avoid
an NPE; if they don't do so immediately the NPE could occur a long way
from the original problem.

Best to report the problem as close to the source as possible - much
easier to debug.

>  Or throw NullPointerException?
>

It's not a null Pointer.

>  On Sat, Jan 16, 2010 at 4:39 AM,  <sebb@apache.org> wrote:
>  > Author: sebb
>  > Date: Sat Jan 16 12:39:20 2010
>  > New Revision: 899929
>  >
>  > URL: http://svn.apache.org/viewvc?rev=899929&view=rev
>  > Log:
>  > LANG-571 ArrayUtils.add(T[] array[, offset], T element) can create unexpected ClassCastException
>  >
>  > Modified:
>  >    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
>  >    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
>  >    commons/proper/lang/trunk/xdocs/changes.xml
>  >
>  > Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
>  > URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java?rev=899929&r1=899928&r2=899929&view=diff
>  > ==============================================================================
>  > --- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
(original)
>  > +++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
Sat Jan 16 12:39:20 2010
>  > @@ -3280,13 +3280,21 @@
>  >      * @param element  the object to add, may be <code>null</code>
>  >      * @return A new array containing the existing elements plus the new element
>  >      * The returned array type will be that of the input array (unless null),
>  > -     * in which case it will have the same type as the element (unless that is
also null)
>  > -     * in which case the returned type will be Object[].
>  > +     * in which case it will have the same type as the element.
>  > +     * If both are null, an IllegalArgumentException is thrown
>  >      * @since 2.1
>  > +     * @throws IllegalArgumentException if both arguments are null
>  >      */
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message