HBASE-13995 ServerName is not fully case insensitive
This commit is contained in:
parent
348a11ad55
commit
5ee11840f6
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -108,5 +108,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