Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static class ReplicationPeerConfigBuilderImpl implements ReplicationPeerConfigBu

@Override
public ReplicationPeerConfigBuilder setClusterKey(String clusterKey) {
this.clusterKey = clusterKey;
this.clusterKey = clusterKey != null ? clusterKey.trim() : null;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down