HBASE-13995 ServerName is not fully case insensitive
This commit is contained in:
parent
a58848507a
commit
7ece46a607
|
@ -229,7 +229,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
*/
|
||||
static String getServerName(String hostName, int port, long startcode) {
|
||||
final StringBuilder name = new StringBuilder(hostName.length() + 1 + 5 + 1 + 13);
|
||||
name.append(hostName);
|
||||
name.append(hostName.toLowerCase());
|
||||
name.append(SERVERNAME_SEPARATOR);
|
||||
name.append(port);
|
||||
name.append(SERVERNAME_SEPARATOR);
|
||||
|
@ -314,7 +314,7 @@ public class ServerName implements Comparable<ServerName>, Serializable {
|
|||
final ServerName right) {
|
||||
if (left == null) return false;
|
||||
if (right == null) return false;
|
||||
return left.getHostname().equals(right.getHostname()) &&
|
||||
return left.getHostname().compareToIgnoreCase(right.getHostname()) == 0 &&
|
||||
left.getPort() == right.getPort();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,5 +107,16 @@ public class TestServerName {
|
|||
ServerName.getServerStartcodeFromServerName(sn.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHostNameCaseSensitivity() {
|
||||
ServerName lower = ServerName.valueOf("www.example.org", 1234, 5678);
|
||||
ServerName upper = ServerName.valueOf("www.EXAMPLE.org", 1234, 5678);
|
||||
assertEquals(0, lower.compareTo(upper));
|
||||
assertEquals(0, upper.compareTo(lower));
|
||||
assertEquals(lower.hashCode(), upper.hashCode());
|
||||
assertTrue(lower.equals(upper));
|
||||
assertTrue(upper.equals(lower));
|
||||
assertTrue(ServerName.isSameHostnameAndPort(lower, upper));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue