From f4ad68db25844fcdf7c90cfa90614b0dcb97515c Mon Sep 17 00:00:00 2001 From: mokai Date: Sat, 3 Jul 2021 19:03:34 +0800 Subject: [PATCH 1/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java | 3 ++- 1 file changed, 2 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 3b03ae4c7902..4e9b12cd4e50 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 @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; import org.apache.commons.lang3.StringUtils; @@ -183,7 +184,7 @@ static class ReplicationPeerConfigBuilderImpl implements ReplicationPeerConfigBu @Override public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) { - this.clusterKey = clusterKey; + this.clusterKey = Objects.requireNonNull(clusterKey).trim(); return this; } From bfabb4bc845edb85829840bbbbdbd060df562d29 Mon Sep 17 00:00:00 2001 From: mokai Date: Sun, 4 Jul 2021 23:48:17 +0800 Subject: [PATCH 2/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java | 2 +- 1 file changed, 1 insertion(+), 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 4e9b12cd4e50..4cbaf99ac35c 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 @@ -184,7 +184,7 @@ static class ReplicationPeerConfigBuilderImpl implements ReplicationPeerConfigBu @Override public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) { - this.clusterKey = Objects.requireNonNull(clusterKey).trim(); + this.clusterKey = clusterKey == null ? clusterKey : clusterKey.trim(); return this; } From c40df566c9336f88970429d3d7e6be7aff8ddd47 Mon Sep 17 00:00:00 2001 From: mokai Date: Sun, 4 Jul 2021 23:51:27 +0800 Subject: [PATCH 3/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 4cbaf99ac35c..690e59a176ed 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 @@ -7,6 +7,7 @@ * "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 @@ -22,14 +23,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.TreeMap; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Bytes; import org.apache.yetus.audience.InterfaceAudience; - import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils; /** From b7c7750f69337cbd0dd6ea2ddae9242483faa09b Mon Sep 17 00:00:00 2001 From: mokai Date: Sun, 4 Jul 2021 23:52:49 +0800 Subject: [PATCH 4/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java | 2 +- 1 file changed, 1 insertion(+), 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 690e59a176ed..5476a63b0e59 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 @@ -7,7 +7,6 @@ * "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 @@ -29,6 +28,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Bytes; import org.apache.yetus.audience.InterfaceAudience; + import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils; /** From e963201313ddf8ce519a2402b780db647d54c13f Mon Sep 17 00:00:00 2001 From: mokai Date: Mon, 5 Jul 2021 22:34:20 +0800 Subject: [PATCH 5/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java | 2 +- 1 file changed, 1 insertion(+), 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 5476a63b0e59..c8e80c8338c8 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 @@ -183,7 +183,7 @@ static class ReplicationPeerConfigBuilderImpl implements ReplicationPeerConfigBu @Override public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) { - this.clusterKey = clusterKey == null ? clusterKey : clusterKey.trim(); + this.clusterKey = clusterKey != null ? clusterKey.trim() : clusterKey; return this; } From ecc2dece92ddff5da65dfcc7d000813df2f89708 Mon Sep 17 00:00:00 2001 From: mokai Date: Tue, 6 Jul 2021 09:12:39 +0800 Subject: [PATCH 6/8] Update ReplicationPeerConfig.java --- .../apache/hadoop/hbase/replication/ReplicationPeerConfig.java | 2 +- 1 file changed, 1 insertion(+), 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 c8e80c8338c8..ae987b600c5a 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 @@ -183,7 +183,7 @@ static class ReplicationPeerConfigBuilderImpl implements ReplicationPeerConfigBu @Override public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) { - this.clusterKey = clusterKey != null ? clusterKey.trim() : clusterKey; + this.clusterKey = clusterKey != null ? clusterKey.trim() : null; return this; } From 5a88b74e8d4bbdf10f89976e0b45875d01d252c3 Mon Sep 17 00:00:00 2001 From: mokai Date: Tue, 6 Jul 2021 23:32:00 +0800 Subject: [PATCH 7/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../hadoop/hbase/client/TestAsyncReplicationAdminApi.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 479fe6b35a43..b0f6f5602e5c 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 @@ -469,6 +469,14 @@ public void testInvalidClusterKey() throws InterruptedException { } } + @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 { From 51f757d7aa6323142055425d36c0a29ca2b812f1 Mon Sep 17 00:00:00 2001 From: mokai Date: Thu, 8 Jul 2021 23:00:39 +0800 Subject: [PATCH 8/8] HBASE-25700 Enhance znode parent validation when add_peer --- .../hadoop/hbase/client/TestAsyncReplicationAdminApi.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 b0f6f5602e5c..f7a28f9c998c 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 @@ -471,10 +471,10 @@ public void testInvalidClusterKey() throws InterruptedException { @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); + admin.addReplicationPeer(ID_ONE, + ReplicationPeerConfig.newBuilder().setClusterKey(KEY_ONE + " ").build()).get(); + String clusterKey = admin.getReplicationPeerConfig(ID_ONE).get().getClusterKey(); + assertEquals(KEY_ONE, clusterKey); } @Test