SGF-908 - Polish.
Resolves gh-32.
This commit is contained in:
@@ -37,6 +37,8 @@ public class ConnectionEndpoint implements Cloneable, Comparable<ConnectionEndpo
|
||||
protected static final int DEFAULT_PORT = 0; // ephemeral port
|
||||
|
||||
protected static final String DEFAULT_HOST = "localhost";
|
||||
protected static final String GEMFIRE_HOST_PORT_SEPARATOR = "[";
|
||||
protected static final String STANDARD_HOST_PORT_SEPARATOR = ":";
|
||||
|
||||
private final int port;
|
||||
private final String host;
|
||||
@@ -93,13 +95,10 @@ public class ConnectionEndpoint implements Cloneable, Comparable<ConnectionEndpo
|
||||
}
|
||||
|
||||
static int indexOfPort(String host) {
|
||||
for (int i = 0; i < host.length(); ++i) {
|
||||
char c = host.charAt(i);
|
||||
if (':' == c || '[' == c) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
int indexOfPort = host.indexOf(GEMFIRE_HOST_PORT_SEPARATOR);
|
||||
|
||||
return indexOfPort > -1 ? indexOfPort : host.indexOf(STANDARD_HOST_PORT_SEPARATOR);
|
||||
}
|
||||
|
||||
static String parseDigits(String value) {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ConnectionEndpointUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithHostPortWithColon() {
|
||||
public void parseWithHostPortSeparatedByColon() {
|
||||
|
||||
ConnectionEndpoint connectionEndpoint = ConnectionEndpoint.parse("skullbox:12345", 80);
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ConnectionEndpointUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithHostPortHavingSpacingWithColon() {
|
||||
public void parseWithHostPortHavingSpacingSeparatedByColon() {
|
||||
|
||||
ConnectionEndpoint connectionEndpoint = ConnectionEndpoint.parse(" saturn :1 23 4 ");
|
||||
|
||||
@@ -188,7 +188,7 @@ public class ConnectionEndpointUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithHostUsingDefaultPortWithColon() {
|
||||
public void parseWithHostUsingDefaultPortSeparatedByColon() {
|
||||
|
||||
ConnectionEndpoint connectionEndpoint =
|
||||
ConnectionEndpoint.parse("mercury:oneTwoThreeFourFive", 80);
|
||||
@@ -245,7 +245,7 @@ public class ConnectionEndpointUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithPortUsingDefaultHostWithColon() {
|
||||
public void parseWithPortUsingDefaultHostSeparatedByColon() {
|
||||
|
||||
ConnectionEndpoint connectionEndpoint = ConnectionEndpoint.parse(":12345", 80);
|
||||
|
||||
@@ -316,7 +316,9 @@ public class ConnectionEndpointUnitTests {
|
||||
|
||||
@Test
|
||||
public void indexOfPort() {
|
||||
|
||||
assertThat(ConnectionEndpoint.indexOfPort("")).isEqualTo(-1);
|
||||
assertThat(ConnectionEndpoint.indexOfPort(" ")).isEqualTo(-1);
|
||||
assertThat(ConnectionEndpoint.indexOfPort("a")).isEqualTo(-1);
|
||||
assertThat(ConnectionEndpoint.indexOfPort(":")).isEqualTo(0);
|
||||
assertThat(ConnectionEndpoint.indexOfPort("a:")).isEqualTo(1);
|
||||
@@ -434,3 +436,4 @@ public class ConnectionEndpointUnitTests {
|
||||
assertThat(socketAddress.getPort()).isEqualTo(connectionEndpoint.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user