You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2021/11/11 04:14:56 UTC

[orc] branch main updated: ORC-492: Avoid potential ArrayIndexOutOfBoundsException when getting WriterVersionn (#961)

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/main by this push:
     new f7ea8e7  ORC-492: Avoid potential ArrayIndexOutOfBoundsException when getting WriterVersionn (#961)
f7ea8e7 is described below

commit f7ea8e7ee214020a456e8a7e5efec308bc3ed637
Author: Yiqun Zhang <gu...@gmail.com>
AuthorDate: Thu Nov 11 12:14:53 2021 +0800

    ORC-492: Avoid potential ArrayIndexOutOfBoundsException when getting WriterVersionn (#961)
    
    ### What changes were proposed in this pull request?
    
    This pr is aimed at avoiding potential ArrayIndexOutOfBoundsException possible when getting WriterVersion.
    
    ### Why are the changes needed?
    
    Fix bug.
    Return the Future version when val is equal to versions.length to avoid throwing ArrayIndexOutOfBoundsException on line 248.
    
    ### How was this patch tested?
    
    Pass the CIs.
---
 java/core/src/java/org/apache/orc/OrcFile.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/core/src/java/org/apache/orc/OrcFile.java b/java/core/src/java/org/apache/orc/OrcFile.java
index 6993f4b..a23a3f5 100644
--- a/java/core/src/java/org/apache/orc/OrcFile.java
+++ b/java/core/src/java/org/apache/orc/OrcFile.java
@@ -242,7 +242,7 @@ public class OrcFile {
             val + " for writer " + writer);
       }
       WriterVersion[] versions = values[writer.id];
-      if (val < 0 || versions.length < val) {
+      if (val < 0 || versions.length <= val) {
         return FUTURE;
       }
       WriterVersion result = versions[val];