You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Henri Yandell <fl...@gmail.com> on 2010/01/16 20:55:17 UTC
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
Alternatively... should add(null, null) simply return null?
Or throw NullPointerException?
On Sat, Jan 16, 2010 at 4:39 AM, <se...@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
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
Posted by sebb <se...@gmail.com>.
On 16/01/2010, Henri Yandell <fl...@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, <se...@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