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

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/main/java/org/apache/parquet/schema/Type.java 
b/parquet-column/src/main/java/org/apache/parquet/schema/Type.java
index d04695737..7bc1cfdbf 100644
--- a/parquet-column/src/main/java/org/apache/parquet/schema/Type.java
+++ b/parquet-column/src/main/java/org/apache/parquet/schema/Type.java
@@ -283,7 +283,7 @@ protected boolean equals(Type other) {
 
   @Override
   public boolean equals(Object other) {
-    if (!(other instanceof Type) || other == null) {
+    if (other == null || !(other instanceof Type)) {
       return false;
     }
     return equals((Type)other);
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..c3c482622 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
@@ -31,6 +31,16 @@
 import static org.apache.parquet.schema.Type.Repetition.*;
 
 public class TestTypeBuilders {
+
+  @Test
+  public void testTypeEquals() {
+    PrimitiveType type1 = Types.required(INT32).named("type");
+    PrimitiveType type2 = Types.required(INT32).named("type");
+    PrimitiveType type3 = null;
+    Assert.assertTrue(type1.equals(type2));
+    Assert.assertFalse(type1.equals(type3));
+  }
+
   @Test
   public void testPaperExample() {
     MessageType expected =


 

----------------------------------------------------------------
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:
[email protected]


> 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)

Reply via email to