You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/10/05 20:02:07 UTC

[GitHub] [hadoop] steveloughran commented on a diff in pull request #4957: HADOOP-18471. Fixed ArrayIndexOutOfBoundsException in class DefaultStringifier

steveloughran commented on code in PR #4957:
URL: https://github.com/apache/hadoop/pull/4957#discussion_r985588594


##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestDefaultStringifier.java:
##########
@@ -107,6 +108,12 @@ public void testStoreLoadArray() throws IOException {
     Integer[] array = new Integer[] {1,2,3,4,5};
 
 
+    try {

Review Comment:
   use our `LambdaTestUtils.intercept()` here; it's a reimplementation of scalatest's and straightforward to use it.



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/DefaultStringifier.java:
##########
@@ -158,6 +158,9 @@ public static <K> K load(Configuration conf, String keyName,
   public static <K> void storeArray(Configuration conf, K[] items,
       String keyName) throws IOException {
 
+    if (items.length == 0) {
+      throw new IndexOutOfBoundsException();
+    }
     DefaultStringifier<K> stringifier = new DefaultStringifier<K>(conf, 
         GenericsUtil.getClass(items[0]));

Review Comment:
   won't this trigger the same exception automatically? what does the test do before the new lines are added



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org