You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/11/12 14:41:00 UTC

[jira] [Commented] (PARQUET-1338) PrimitiveType.equals throw NPE

    [ https://issues.apache.org/jira/browse/PARQUET-1338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683884#comment-16683884 ] 

ASF GitHub Bot commented on PARQUET-1338:
-----------------------------------------

wangyum closed pull request #498: PARQUET-1338: Fix PrimitiveType.equals throw NPE
URL: https://github.com/apache/parquet-mr/pull/498
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/parquet-column/src/main/java/org/apache/parquet/schema/PrimitiveType.java b/parquet-column/src/main/java/org/apache/parquet/schema/PrimitiveType.java
index 08adfbe99..1d08b2198 100644
--- a/parquet-column/src/main/java/org/apache/parquet/schema/PrimitiveType.java
+++ b/parquet-column/src/main/java/org/apache/parquet/schema/PrimitiveType.java
@@ -611,7 +611,7 @@ protected boolean typeEquals(Type other) {
    */
   @Override
   protected boolean equals(Type other) {
-    if (!other.isPrimitive()) {
+    if (other == null || !other.isPrimitive()) {
       return false;
     }
     PrimitiveType otherPrimitive = other.asPrimitiveType();
diff --git a/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java b/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java
index a42e9e33b..6212de65e 100644
--- a/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java
+++ b/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java
@@ -1437,6 +1437,17 @@ public void testDecimalLogicalTypeWithDeprecatedPrecisionMismatch() {
       .precision(5).named("aDecimal");
   }
 
+  @Test
+  public void testTypeEquals() {
+    PrimitiveType type1 = Types.required(INT32).named("type");
+    PrimitiveType type2 = Types.required(INT32).named("type");
+    PrimitiveType type3 = null;
+    GroupType type4 = null;
+    Assert.assertTrue(type1.equals(type2));
+    Assert.assertFalse(type1.equals(type3));
+    Assert.assertFalse(type1.equals(type4));
+  }
+
   /**
    * A convenience method to avoid a large number of @Test(expected=...) tests
    * @param message A String message to describe this assertion


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> PrimitiveType.equals throw NPE
> ------------------------------
>
>                 Key: PARQUET-1338
>                 URL: https://issues.apache.org/jira/browse/PARQUET-1338
>             Project: Parquet
>          Issue Type: Bug
>          Components: parquet-mr
>    Affects Versions: 1.10.1
>            Reporter: Yuming Wang
>            Assignee: Yuming Wang
>            Priority: Major
>              Labels: pull-request-available
>
> Error message:
> {noformat}
> java.lang.NullPointerException
> 	at org.apache.parquet.schema.PrimitiveType.equals(PrimitiveType.java:614)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)