[
https://issues.apache.org/jira/browse/FLINK-4032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15331391#comment-15331391
]
ASF GitHub Bot commented on FLINK-4032:
---------------------------------------
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.
> Replace all usage of Guava Preconditions
> ----------------------------------------
>
> Key: FLINK-4032
> URL: https://issues.apache.org/jira/browse/FLINK-4032
> Project: Flink
> Issue Type: Improvement
> Affects Versions: 1.1.0
> Reporter: Chesnay Schepler
> Assignee: Chesnay Schepler
> Priority: Trivial
> Fix For: 1.1.0
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)