Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/2084#discussion_r67120005
--- Diff: flink-core/src/main/java/org/apache/flink/util/Preconditions.java
---
@@ -234,6 +234,22 @@ public static void checkElementIndex(int index, int
size) {
}
}
+ /**
+ * Ensures that the given index is valid for an array, list or string
of the given size.
+ *
+ * @param index index to check
+ * @param size size of the array, list or string
+ *
+ * @throws IllegalArgumentException Thrown, if size is negative.
+ * @throws IndexOutOfBoundsException Thrown, if the index negative or
greater than or equal to size
+ */
+ public static void checkElementIndex(int index, int size, @Nullable
String errorMessage) {
+ checkArgument(size >= 0, "Size was negative.");
+ if (index < 0 || index >= size) {
+ throw new IndexOutOfBoundsException(errorMessage + "
Index: " + index + ", Size: " + size);
--- End diff --
other Preconditions methods print also print "null" if no error message was
given. granted, they use String.valueOf(errorMessage), but it's essentially the
same.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---