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

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 3294d32  HBASE-25700 Enhance znode parent validation when add_peer 
(#3458)
3294d32 is described below

commit 3294d32f4686ba31397ae1c03063a655fa13390a
Author: mokai <[email protected]>
AuthorDate: Sun Jul 11 20:45:25 2021 +0800

    HBASE-25700 Enhance znode parent validation when add_peer (#3458)
    
    Signed-off-by: Duo Zhang <[email protected]>
    Signed-off-by: Pankaj Kumar <[email protected]>
---
 .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java    | 2 +-
 .../apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java  | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java
index 534357a..2f871a3 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationPeerConfig.java
@@ -263,7 +263,7 @@ public class ReplicationPeerConfig {
 
     @Override
     public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) {
-      this.clusterKey = clusterKey;
+      this.clusterKey = clusterKey != null ? clusterKey.trim() : null;
       return this;
     }
 
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
index 5aecd31..5a0fc97 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApi.java
@@ -478,6 +478,14 @@ public class TestAsyncReplicationAdminApi extends 
TestAsyncAdminBase {
   }
 
   @Test
+  public void testClusterKeyWithTrailingSpace() throws Exception {
+    admin.addReplicationPeer(ID_ONE,
+      ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE + " 
").build()).get();
+    String clusterKey = 
admin.getReplicationPeerConfig(ID_ONE).get().getClusterKey();
+    assertEquals(KEY_ONE, clusterKey);
+  }
+
+  @Test
   public void testInvalidReplicationEndpoint() throws InterruptedException {
     try {
       admin.addReplicationPeer(ID_ONE,

Reply via email to