HBASE-25700 Enhance znode parent validation when add_peer (#3458)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
This commit is contained in:
mokai 2021-07-11 20:45:25 +08:00 committed by Duo Zhang
parent b86d2d4020
commit 3294d32f46
2 changed files with 9 additions and 1 deletions

View File

@ -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;
}

View File

@ -477,6 +477,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 {