public static <T> T getElementAtIndex(T[] array, int index, T defaultValue) {
    try {
      return array[index];
    } catch (ArrayIndexOutOfBoundsException ignore) {
      return defaultValue;
    }
  }
Gets the element at index in the array in a bound-safe manner. If index is not a valid index in
the given array, then the default value is returned.
<p>

@param <T> the class type of the elements in the array.
@param array the array from which the element at index is retrieved.
@param index the index into the array to retrieve the element.
@param defaultValue the default value of element type to return in the event that the array
       index is invalid.
@return the element at index from the array or the default value if the index is invalid.
geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java