HBASE-20783 NEP encountered when rolling update from master with an async peer 
to branch HBASE-19064

Signed-off-by: zhangduo <zhang...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/045f5ef8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/045f5ef8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/045f5ef8

Branch: refs/heads/HBASE-19064
Commit: 045f5ef82f39977c3ad03fe4fa95439cdc130abc
Parents: 7b4c1fb
Author: huzheng <open...@gmail.com>
Authored: Mon Jun 25 16:49:02 2018 +0800
Committer: zhangduo <zhang...@apache.org>
Committed: Thu Jun 28 11:22:31 2018 +0800

----------------------------------------------------------------------
 .../hbase/replication/SyncReplicationState.java |  5 ++-
 .../replication/TestSyncReplicationState.java   | 45 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/045f5ef8/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/SyncReplicationState.java
----------------------------------------------------------------------
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/SyncReplicationState.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/SyncReplicationState.java
index de9576c..448603c 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/SyncReplicationState.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/SyncReplicationState.java
@@ -68,7 +68,10 @@ public enum SyncReplicationState {
   }
 
   public static SyncReplicationState parseFrom(byte[] bytes) throws 
InvalidProtocolBufferException {
+    if (bytes == null) {
+      return SyncReplicationState.NONE;
+    }
     return 
ReplicationPeerConfigUtil.toSyncReplicationState(ReplicationProtos.SyncReplicationState
-      .parseFrom(Arrays.copyOfRange(bytes, ProtobufUtil.lengthOfPBMagic(), 
bytes.length)));
+        .parseFrom(Arrays.copyOfRange(bytes, ProtobufUtil.lengthOfPBMagic(), 
bytes.length)));
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/045f5ef8/hbase-client/src/test/java/org/apache/hadoop/hbase/replication/TestSyncReplicationState.java
----------------------------------------------------------------------
diff --git 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/replication/TestSyncReplicationState.java
 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/replication/TestSyncReplicationState.java
new file mode 100644
index 0000000..6921252
--- /dev/null
+++ 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/replication/TestSyncReplicationState.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.replication;
+
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category({ ClientTests.class, SmallTests.class })
+public class TestSyncReplicationState {
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+      HBaseClassTestRule.forClass(TestSyncReplicationState.class);
+
+  @Test
+  public void testSyncReplicationStateParseFrom() throws Exception {
+    Assert.assertEquals(SyncReplicationState.parseFrom(null), 
SyncReplicationState.NONE);
+    for (SyncReplicationState state : SyncReplicationState.values()) {
+      byte[] data = SyncReplicationState.toByteArray(state);
+      SyncReplicationState actualState = SyncReplicationState.parseFrom(data);
+      Assert.assertEquals(state, actualState);
+    }
+  }
+}

Reply via email to