commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1073) Read wrong component type of array in add in ArrayUtils
Date Sun, 14 Dec 2014 21:31:13 GMT

     [ https://issues.apache.org/jira/browse/LANG-1073?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Benedikt Ritter updated LANG-1073:
----------------------------------
    Fix Version/s:     (was: Discussion)
                   3.4

> Read wrong component type of array in add in ArrayUtils
> -------------------------------------------------------
>
>                 Key: LANG-1073
>                 URL: https://issues.apache.org/jira/browse/LANG-1073
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.3.2
>            Reporter: haiyang li
>            Assignee: Bruno P. Kinoshita
>            Priority: Minor
>             Fix For: 3.4
>
>
> {code:title=org.apache.commons.lang3.ArrayUtils.java|borderStyle=solid}
>     public static <T> T[] add(final T[] array, final T element) {
>         Class<?> type;
>         if (array != null){
>             type = array.getClass();
>         } else if (element != null) {
>             type = element.getClass();
>         } else {
>             throw new IllegalArgumentException("Arguments cannot both be null");
>         }
>         .......
>     }
> {code}
> I think it should be:
> {code:title=org.apache.commons.lang3.ArrayUtils.java|borderStyle=solid}
>     public static <T> T[] add(final T[] array, final T element) {
>         Class<?> type;
>         if (array != null){
>             type = array.getClass().getComponentType();
>         } else if (element != null) {
>             type = element.getClass();
>         } else {
>             throw new IllegalArgumentException("Arguments cannot both be null");
>         }
>         .......
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message