You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sk...@apache.org on 2020/01/29 21:48:03 UTC

[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5618: Addendum patch for NPE on sourceValue=null

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

skadam pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
     new f838238  PHOENIX-5618: Addendum patch for NPE on sourceValue=null
f838238 is described below

commit f838238febe526cc5ef9d2f7ae7ca137229a9d7b
Author: Gokcen Iskender <gi...@salesforce.com>
AuthorDate: Wed Jan 29 10:35:35 2020 -0800

    PHOENIX-5618: Addendum patch for NPE on sourceValue=null
    
    Signed-off-by: s.kadam <s....@apache.org>
---
 .../NonParameterizedIndexScrutinyToolIT.java       | 51 ++++++++++++++++++++++
 .../mapreduce/index/IndexScrutinyMapper.java       | 11 ++---
 2 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java
index f70e6a2..cd73af5 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java
@@ -88,6 +88,57 @@ public class NonParameterizedIndexScrutinyToolIT extends IndexScrutinyToolBaseIT
             counters = job.getCounters();
             assertEquals(2, getCounterValue(counters, VALID_ROW_COUNT));
             assertEquals(1, getCounterValue(counters, INVALID_ROW_COUNT));
+
+            // Have source null
+            upsertRow(upsertDataStmt, 4, "name-4", null);
+            conn.commit();
+
+            upsertIndexStmt.setString(1, "name-4");
+            upsertIndexStmt.setInt(2, 4);
+            upsertIndexStmt.setBytes(3, new byte[] {0, 0, 1, 1});
+            upsertIndexStmt.executeUpdate();
+            conn.commit();
+
+            completedJobs = runScrutiny(null, dataTableName, indexTableName);
+            job = completedJobs.get(0);
+            assertTrue(job.isSuccessful());
+            counters = job.getCounters();
+            assertEquals(2, getCounterValue(counters, VALID_ROW_COUNT));
+            assertEquals(2, getCounterValue(counters, INVALID_ROW_COUNT));
+
+            // Have target null
+            upsertRow(upsertDataStmt, 5, "name-5", new byte[] {0, 1, 1, 1});
+            conn.commit();
+
+            upsertIndexStmt.setString(1, "name-5");
+            upsertIndexStmt.setInt(2, 5);
+            upsertIndexStmt.setBytes(3, null);
+            upsertIndexStmt.executeUpdate();
+            conn.commit();
+
+            completedJobs = runScrutiny(null, dataTableName, indexTableName);
+            job = completedJobs.get(0);
+            assertTrue(job.isSuccessful());
+            counters = job.getCounters();
+            assertEquals(2, getCounterValue(counters, VALID_ROW_COUNT));
+            assertEquals(3, getCounterValue(counters, INVALID_ROW_COUNT));
+
+            // Have both of them null
+            upsertRow(upsertDataStmt, 6, "name-6", null);
+            conn.commit();
+
+            upsertIndexStmt.setString(1, "name-6");
+            upsertIndexStmt.setInt(2, 6);
+            upsertIndexStmt.setBytes(3, null);
+            upsertIndexStmt.executeUpdate();
+            conn.commit();
+
+            completedJobs = runScrutiny(null, dataTableName, indexTableName);
+            job = completedJobs.get(0);
+            assertTrue(job.isSuccessful());
+            counters = job.getCounters();
+            assertEquals(3, getCounterValue(counters, VALID_ROW_COUNT));
+            assertEquals(3, getCounterValue(counters, INVALID_ROW_COUNT));
         }
     }
 
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java
index b7a8cff..9099f05 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java
@@ -440,7 +440,9 @@ public class IndexScrutinyMapper extends Mapper<NullWritable, PhoenixIndexDBWrit
         for (int i = startIndex; i < sourceValues.size(); i++) {
             Object targetValue = targetValues.get(i);
             Object sourceValue = sourceValues.get(i);
-            if (targetValue != null) {
+            if (sourceValue == null && targetValue == null) {
+                continue;
+            } else if (sourceValue != null && targetValue != null) {
                 if (sourceValue.getClass().isArray()) {
                     if (compareArrayTypes(sourceValue, targetValue)) {
                         continue;
@@ -450,10 +452,9 @@ public class IndexScrutinyMapper extends Mapper<NullWritable, PhoenixIndexDBWrit
                         continue;
                     }
                 }
-                context.getCounter(PhoenixScrutinyJobCounters.BAD_COVERED_COL_VAL_COUNT)
-                        .increment(1);
-                return false;
-            }
+            } 
+            context.getCounter(PhoenixScrutinyJobCounters.BAD_COVERED_COL_VAL_COUNT).increment(1);
+            return false;
         }
         return true;
     }