[
https://issues.apache.org/jira/browse/LANG-571?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sebb resolved LANG-571.
-----------------------
Resolution: Fixed
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
> ArrayUtils.add(T[] array, T element) can create unexpected ClassCastException
> -----------------------------------------------------------------------------
>
> Key: LANG-571
> URL: https://issues.apache.org/jira/browse/LANG-571
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Reporter: Sebb
> Fix For: 3.0
>
>
> ArrayUtils.add(T[] array, T element) can create an unexpected
> ClassCastException.
> For example, the following code compiles without a warning:
> {code}
> String[] sa = ArrayUtils.add(stringArray, aString);
> {code}
> and works fine, provided at least one of the parameters is non-null. However,
> if both parameters are null, the add() method returns an Object[] array,
> hence the Exception.
> If both parameters are null, it's not possible to determine the correct array
> type to return, so it seems to me this should be disallowed.
> I think the method ought to be changed to throw IllegalParameterException
> when both parameters are null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.