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

ArrayUtils.isEquals() throws ClassCastException when array1 and array2 are different dimension

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None
    • None
    • Operating System: other
      Platform: Other

    • 30815

    Description

      ArrayUtils.isEquals() throws ClassCastException when array1 and array2 are
      different dimension.

      For example:

      boolean[][] array1 = new boolean[][] {

      { true, false }, { true, false }

      };
      boolean[] array2 = new boolean[]

      { false, true }

      ;
      if( ArrayUtils.isEquals( array1, array2 ) ){ // <== ClassCastException
      :

      How about the following implementation to avoid the exception?

      public static boolean isEquals(final Object array1, final Object array2) {
      if( !isSameType( array1, array2 ) ) return false;
      return new EqualsBuilder().append(array1, array2).isEquals();
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            koji.sekiguchi@bluemartini.com Koji Sekiguchi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: