liuml07 commented on a change in pull request #2036:
URL: https://github.com/apache/hadoop/pull/2036#discussion_r432308833
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
##########
@@ -95,7 +95,25 @@ public void testAvoidLoopbackTcpSockets() throws Throwable {
assertInException(se, "Invalid argument");
}
}
-
+
+ @Test
+ public void testInvalidAddress() throws Throwable {
+ Configuration conf = new Configuration();
+
+ Socket socket = NetUtils.getDefaultSocketFactory(conf)
+ .createSocket();
+ socket.bind(new InetSocketAddress("127.0.0.1", 0));
+ try {
+ NetUtils.connect(socket,
+ new InetSocketAddress("invalid-test-host",
+ 0), 20000);
+ socket.close();
+ fail("Should not have connected");
+ } catch (UnknownHostException ce) {
+ System.err.println("Got exception: " + ce);
Review comment:
nit: I know this is following existing test case, but since we now have
a logger, we can use this:
```
LOG.info("Got expected exception", uhe);
```
Sytem.err in test code is not friendly to test output/log interpretation.
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java
##########
@@ -534,6 +535,8 @@ public static void connect(Socket socket,
}
} catch (SocketTimeoutException ste) {
throw new ConnectTimeoutException(ste.getMessage());
+ } catch (UnresolvedAddressException ue) {
Review comment:
nit: call it `uae`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]