From b8ec2fb2e40fa01bbfb517b8eef05da48d1234bd Mon Sep 17 00:00:00 2001 From: Sakthi Date: Fri, 23 Feb 2018 12:09:19 -0800 Subject: [PATCH] HBASE-18864 Fixed NullPointerException thrown while adding rows to a table from peer cluster, with replication factor other than 0 or 1 --- .../src/main/java/org/apache/hadoop/hbase/wal/WALKey.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALKey.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALKey.java index 05acd7208818f9c1769e6d0b748a63a18944b936..9d5610cfb85d98a4e0d8238633f9e3bd0aa48f49 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALKey.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALKey.java @@ -615,8 +615,14 @@ public class WALKey implements SequenceId, Comparable { for (Map.Entry e : scopes.entrySet()) { ByteString family = (compressionContext == null) ? ByteStringer.wrap(e.getKey()) : compressor.compress(e.getKey(), compressionContext.familyDict); - builder.addScopes(FamilyScope.newBuilder() - .setFamily(family).setScopeType(ScopeType.valueOf(e.getValue()))); + ScopeType scopeType = ScopeType.valueOf(e.getValue()); + if (scopeType == null) { + // Any value other than '0' for the REPLICATION_SCOPE will be + // replaced with '1' (REPLICATION_SCOPE_GLOBAL) + LOG.warn("Invalid value for REPLICATION_SCOPE = " + e.getValue()); + scopeType = ScopeType.REPLICATION_SCOPE_GLOBAL; + } + builder.addScopes(FamilyScope.newBuilder().setFamily(family).setScopeType(scopeType)); } } return builder; -- 2.14.3 (Apple Git-98)