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 GitHub
parent e65fc9226f
commit bb84892550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -183,7 +183,7 @@ public class ReplicationPeerConfig {
@Override @Override
public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) { public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) {
this.clusterKey = clusterKey; this.clusterKey = clusterKey != null ? clusterKey.trim() : null;
return this; return this;
} }

View File

@ -469,6 +469,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 @Test
public void testInvalidReplicationEndpoint() throws InterruptedException { public void testInvalidReplicationEndpoint() throws InterruptedException {
try { try {