steveloughran commented on code in PR #7428:
URL: https://github.com/apache/hadoop/pull/7428#discussion_r1973737619


##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java:
##########
@@ -801,6 +802,48 @@ public void testBindToLocalAddress() throws Exception {
         .bindToLocalAddress(NetUtils.getLocalInetAddress("127.0.0.1"), true));
   }
 
+  public static class WrappedIOException extends IOException {
+    public WrappedIOException(String msg, Throwable cause) {
+      super(msg, cause);
+    }
+  }
+
+  private static class PrivateIOException extends IOException {
+    PrivateIOException(String msg, Throwable cause) {
+      super(msg, cause);
+    }
+  }
+
+  @Test
+  public void testAddNodeNameToIOException() {
+    IOException e0 = new IOException("test123");
+    assertNull(e0.getCause());

Review Comment:
   can we have assertj here..as we do that move to junit5, best to start off 
with the cross-version test asserts.
   
   actually, given there's so many assertNull(throwable.getCause(), what about 
a new method `assertNullCause(Throwable)` and use through this



##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java:
##########
@@ -801,6 +802,48 @@ public void testBindToLocalAddress() throws Exception {
         .bindToLocalAddress(NetUtils.getLocalInetAddress("127.0.0.1"), true));
   }
 
+  public static class WrappedIOException extends IOException {
+    public WrappedIOException(String msg, Throwable cause) {
+      super(msg, cause);
+    }
+  }
+
+  private static class PrivateIOException extends IOException {
+    PrivateIOException(String msg, Throwable cause) {
+      super(msg, cause);
+    }
+  }
+
+  @Test
+  public void testAddNodeNameToIOException() {
+    IOException e0 = new IOException("test123");
+    assertNull(e0.getCause());
+    IOException new0 = NetUtils.addNodeNameToIOException(e0, "node123");
+    assertNull(new0.getCause());
+    assertEquals("node123: test123", new0.getMessage());
+
+    IOException e1 = new IOException("test456", new 
IllegalStateException("deliberate"));
+    IOException new1 = NetUtils.addNodeNameToIOException(e1, "node456");
+    assertEquals(e1.getCause(), new1.getCause());

Review Comment:
   assertEquals or assertSame?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to