Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1073

Read wrong component type of array in add in ArrayUtils

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.3.2
    • 3.4
    • lang.*
    • None

    Description

      org.apache.commons.lang3.ArrayUtils.java
          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");
              }
              .......
          }
      

      I think it should be:

      org.apache.commons.lang3.ArrayUtils.java
          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");
              }
              .......
          }
      

      Attachments

        Activity

          People

            kinow Bruno P. Kinoshita
            lihy70 haiyang li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: