Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Converters.java #2846

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* @author daihuabin
* @author John Blum
* @author Sorokin Evgeniy
* @author Habip Kenan Uskudar
*/
public abstract class Converters {

Expand Down Expand Up @@ -569,8 +570,9 @@ enum ClusterNodesConverter implements Converter<String, RedisClusterNode> {

@Override
public RedisClusterNode convert(String source) {

String[] args = source.split(" ");
String filteredSource = source.replace(", ", " ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't do the job especially when auxilliary fields are appended, then the port part is immediately followed by aux fields.


String[] args = filteredSource.split(" ");

Matcher matcher = clusterEndpointPattern.matcher(args[HOST_PORT_INDEX]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @author Christoph Strobl
* @author Mark Paluch
* @author Sorokin Evgeniy
* @author Habip Kenan Uskudar
*/
class ConvertersUnitTests {

Expand Down Expand Up @@ -72,6 +73,8 @@ class ConvertersUnitTests {

private static final String CLUSTER_NODE_WITH_SINGLE_INVALID_IPV6_HOST = "67adfe3df1058896e3cb49d2863e0f70e7e159fa 2a02:6b8:c67:9c:0:6d8b:33da:5a2c: master,nofailover - 0 1692108412315 1 connected 0-5460";

private static final String CLUSTER_NODE_ENTRY_WITH_EMPTY_HUMAN_READABLE_CLUSTER_NAME_IN_GCP_MEMORY_STORE = "3765733728631672640db35fd2f04743c03119c6 10.180.0.33:11003@16379, master - 0 1708041426947 2 connected 5462-10922";

@Test // DATAREDIS-315
void toSetOfRedis30ClusterNodesShouldConvertSingleStringNodesResponseCorrectly() {

Expand Down Expand Up @@ -263,6 +266,22 @@ void toClusterNodeWithIPv6HostnameSquareBrackets() {
assertThat(node.getSlotRange().getSlots().size()).isEqualTo(5461);
}

@Test // DATAREDIS-2862
void toSetOfRedisClusterNodesShouldConvertNodesWithEmptyHumanReadableClusterNameInGcpMemoryStoreCorrectly() {

RedisClusterNode node = Converters.toClusterNode(CLUSTER_NODE_ENTRY_WITH_EMPTY_HUMAN_READABLE_CLUSTER_NAME_IN_GCP_MEMORY_STORE);

assertThat(node.getId()).isEqualTo("3765733728631672640db35fd2f04743c03119c6");
assertThat(node.getHost()).isEqualTo("10.180.0.33");
assertThat(node.hasValidHost()).isTrue();
assertThat(node.getPort()).isEqualTo(11003);
assertThat(node.getType()).isEqualTo(NodeType.MASTER);
assertThat(node.getFlags()).contains(Flag.MASTER);
assertThat(node.getLinkState()).isEqualTo(LinkState.CONNECTED);
assertThat(node.getSlotRange().contains(5462)).isTrue();
assertThat(node.getSlotRange().contains(10922)).isTrue();
}

@Test // GH-2678
void toClusterNodeWithInvalidIPv6Hostname() {
assertThatIllegalArgumentException()
Expand Down