You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by wi...@apache.org on 2022/10/19 02:13:53 UTC
[orc] branch branch-1.8 updated: ORC-1291: Fix NPE in `TypeDescription.hashCode()` for primitive types
This is an automated email from the ASF dual-hosted git repository.
william pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/branch-1.8 by this push:
new 7b29b0098 ORC-1291: Fix NPE in `TypeDescription.hashCode()` for primitive types
7b29b0098 is described below
commit 7b29b0098dd7d052485c165bdff1e56640280789
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Tue Oct 18 19:13:32 2022 -0700
ORC-1291: Fix NPE in `TypeDescription.hashCode()` for primitive types
### What changes were proposed in this pull request?
This PR aims to fix NPE in `TypeDescription.hashCode()` for primitive types.
### Why are the changes needed?
To fix a regression at 1.8.0.
### How was this patch tested?
Pass the CI with the newly added test case.
Closes #1283 from dongjoon-hyun/ORC-1291.
Authored-by: Dongjoon Hyun <do...@apache.org>
Signed-off-by: William Hyun <wi...@apache.org>
(cherry picked from commit d1971ea7ffa5a15e49dff2a8a7085db2e93aea9a)
Signed-off-by: William Hyun <wi...@apache.org>
---
java/core/src/java/org/apache/orc/TypeDescription.java | 4 +++-
java/core/src/test/org/apache/orc/TestTypeDescription.java | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/java/core/src/java/org/apache/orc/TypeDescription.java b/java/core/src/java/org/apache/orc/TypeDescription.java
index 5f2e0808c..8c02e6807 100644
--- a/java/core/src/java/org/apache/orc/TypeDescription.java
+++ b/java/core/src/java/org/apache/orc/TypeDescription.java
@@ -387,7 +387,9 @@ public class TypeDescription
final int prime = 31;
int result = 1;
result = prime * result + category.hashCode();
- result = prime * result + children.hashCode();
+ if (children != null) {
+ result = prime * result + children.hashCode();
+ }
result = prime * result + maxLength;
result = prime * result + precision;
result = prime * result + scale;
diff --git a/java/core/src/test/org/apache/orc/TestTypeDescription.java b/java/core/src/test/org/apache/orc/TestTypeDescription.java
index 4129419e0..7dba23a9f 100644
--- a/java/core/src/test/org/apache/orc/TestTypeDescription.java
+++ b/java/core/src/test/org/apache/orc/TestTypeDescription.java
@@ -517,4 +517,10 @@ public class TestTypeDescription {
assertEquals(0, type.getAttributeNames().size());
}
+
+ @Test
+ public void testHashCode() {
+ // Should not throw NPE
+ TypeDescription.fromString("int").hashCode();
+ }
}