Skip to content

Commit ec053b3

Browse files
committed
HDFS-17841. TestDFSUtil fails with JDK17.
1 parent 5000a98 commit ec053b3

File tree

1 file changed

+17
-8
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs

1 file changed

+17
-8
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,10 @@ public void testHANameNodesWithFederation() throws URISyntaxException {
555555
assertTrue(HAUtil.isHAEnabled(conf, "ns2"));
556556
assertFalse(HAUtil.isHAEnabled(conf, "ns3"));
557557

558-
assertEquals(resolvedName(NS1_NN1_HOST), map.get("ns1").get("ns1-nn1").toString());
559-
assertEquals(resolvedName(NS1_NN2_HOST), map.get("ns1").get("ns1-nn2").toString());
560-
assertEquals(resolvedName(NS2_NN1_HOST), map.get("ns2").get("ns2-nn1").toString());
561-
assertEquals(resolvedName(NS2_NN2_HOST), map.get("ns2").get("ns2-nn2").toString());
558+
assertInetSocketAddress(NS1_NN1_HOST, map.get("ns1").get("ns1-nn1"));
559+
assertInetSocketAddress(NS1_NN2_HOST, map.get("ns1").get("ns1-nn2"));
560+
assertInetSocketAddress(NS2_NN1_HOST, map.get("ns2").get("ns2-nn1"));
561+
assertInetSocketAddress(NS2_NN2_HOST, map.get("ns2").get("ns2-nn2"));
562562

563563
assertEquals(NS1_NN1_HOST,
564564
DFSUtil.getNamenodeServiceAddr(conf, "ns1", "ns1-nn1"));
@@ -626,16 +626,25 @@ public void getNameNodeServiceAddr() throws IOException {
626626
}
627627

628628
@Test
629-
public void testGetHaNnHttpAddresses() throws IOException {
629+
public void testGetHaNnHttpAddresses() {
630630
final String LOGICAL_HOST_NAME = "ns1";
631631

632632
Configuration conf = createWebHDFSHAConfiguration(LOGICAL_HOST_NAME, NS1_NN1_ADDR, NS1_NN2_ADDR);
633633

634634
Map<String, Map<String, InetSocketAddress>> map =
635635
DFSUtilClient.getHaNnWebHdfsAddresses(conf, "webhdfs");
636636

637-
assertEquals(resolvedName(NS1_NN1_ADDR), map.get("ns1").get("nn1").toString());
638-
assertEquals(resolvedName(NS1_NN2_ADDR), map.get("ns1").get("nn2").toString());
637+
assertInetSocketAddress(NS1_NN1_ADDR, map.get("ns1").get("nn1"));
638+
assertInetSocketAddress(NS1_NN2_ADDR, map.get("ns1").get("nn2"));
639+
}
640+
641+
static void assertInetSocketAddress(String expected, InetSocketAddress computed) {
642+
final int i = expected.indexOf(':');
643+
final String host = expected.substring(0, i);
644+
final int port = Integer.parseInt(expected.substring(i + 1));
645+
assertEquals(host, computed.getHostName());
646+
assertEquals(port, computed.getPort());
647+
assertEquals(InetSocketAddress.createUnresolved(host, port), computed);
639648
}
640649

641650
private static Configuration createWebHDFSHAConfiguration(String logicalHostName, String nnaddr1, String nnaddr2) {
@@ -956,7 +965,7 @@ public void testAssertAllResultsEqual() {
956965
checkAllResults(new Long[]{1l}, true);
957966
checkAllResults(new Long[]{1l, 1l}, true);
958967
checkAllResults(new Long[]{1l, 1l, 1l}, true);
959-
checkAllResults(new Long[]{new Long(1), new Long(1)}, true);
968+
checkAllResults(new Long[]{1L, 1L}, true);
960969
checkAllResults(new Long[]{null, null, null}, true);
961970

962971
checkAllResults(new Long[]{1l, 2l}, false);

0 commit comments

Comments
 (0)