hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prasan...@apache.org
Subject hive git commit: HIVE-5623: ORC accessing array column that's empty will fail with java out of bound exception (Prasanth Jayachandran reviewed by Ashutosh Chauhan)
Date Mon, 14 Sep 2015 21:08:55 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-1 26bcf473a -> 1649ab0d0


HIVE-5623: ORC accessing array column that's empty will fail with java out of bound exception
(Prasanth Jayachandran reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1649ab0d
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1649ab0d
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1649ab0d

Branch: refs/heads/branch-1
Commit: 1649ab0d0d705154c51b6dfa6728eccdb615afbf
Parents: 26bcf47
Author: Prasanth Jayachandran <j.prasanth.j@gmail.com>
Authored: Mon Sep 14 16:08:36 2015 -0500
Committer: Prasanth Jayachandran <j.prasanth.j@gmail.com>
Committed: Mon Sep 14 16:08:36 2015 -0500

----------------------------------------------------------------------
 ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java     | 2 +-
 ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestOrcStruct.java | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/1649ab0d/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java
index b1a32bc..7a17b92 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcStruct.java
@@ -435,7 +435,7 @@ final public class OrcStruct implements Writable {
 
     @Override
     public Object getListElement(Object list, int i) {
-      if (list == null) {
+      if (list == null || i < 0 || i >= getListLength(list)) {
         return null;
       }
       return ((List) list).get(i);

http://git-wip-us.apache.org/repos/asf/hive/blob/1649ab0d/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestOrcStruct.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestOrcStruct.java b/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestOrcStruct.java
index 8fc0693..2e431c8 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestOrcStruct.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestOrcStruct.java
@@ -94,6 +94,8 @@ public class TestOrcStruct {
         inspector.getAllStructFieldRefs().get(12).getFieldObjectInspector();
     assertEquals(ObjectInspector.Category.LIST, listOI.getCategory());
     assertEquals(10, listOI.getListElement(list, 10));
+    assertEquals(null, listOI.getListElement(list, -1));
+    assertEquals(null, listOI.getListElement(list, 13));
     assertEquals(13, listOI.getListLength(list));
 
     Map<Integer, Integer> map = new HashMap<Integer,Integer>();


Mime
View raw message