Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,11 @@ public static IOException wrapException(final String destHost,
+ ";"
+ see("SocketException"));
} else {
// Return instance of same type if Exception has a String constructor
// 1. Return instance of same type with exception msg if Exception has a
// String constructor.
// 2. Return instance of same type if Exception doesn't have a String
// constructor.
// Related HADOOP-16453.
return wrapWithMessage(exception,
"DestHost:destPort " + destHost + ":" + destPort
+ " , LocalHost:localPort " + localHost
Expand Down Expand Up @@ -832,9 +836,9 @@ private static <T extends IOException> T wrapWithMessage(
Constructor<? extends Throwable> ctor = clazz.getConstructor(String.class);
Throwable t = ctor.newInstance(msg);
return (T)(t.initCause(exception));
} catch (NoSuchMethodException e) {
return exception;
} catch (Throwable e) {
LOG.trace("Unable to wrap exception of type {}: it has no (String) "
+ "constructor", clazz, e);
throw exception;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1582,11 +1582,10 @@ public void testRpcResponseLimit() throws Throwable {
try {
call(client, 0, addr, conf);
} catch (IOException ioe) {
Throwable t = ioe.getCause();
Assert.assertNotNull(t);
Assert.assertEquals(RpcException.class, t.getClass());
Assert.assertNotNull(ioe);
Assert.assertEquals(RpcException.class, ioe.getClass());
Assert.assertEquals("RPC response exceeds maximum data length",
t.getMessage());
ioe.getMessage());
return;
}
Assert.fail("didn't get limit exceeded");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,9 @@ public void testWrapKerbAuthException() throws Throwable {
@Test
public void testWrapIOEWithNoStringConstructor() throws Throwable {
IOException e = new CharacterCodingException();
IOException wrapped = verifyExceptionClass(e, IOException.class);
assertInException(wrapped, "Failed on local exception");
assertNotInException(wrapped, NetUtils.HADOOP_WIKI);
assertInException(wrapped, "Host Details ");
assertRemoteDetailsIncluded(wrapped);
IOException wrapped =
verifyExceptionClass(e, CharacterCodingException.class);
assertEquals(null, wrapped.getMessage());
}

@Test
Expand All @@ -295,11 +293,8 @@ private TestIOException(String cause){
}
}
IOException e = new TestIOException();
IOException wrapped = verifyExceptionClass(e, IOException.class);
assertInException(wrapped, "Failed on local exception");
assertNotInException(wrapped, NetUtils.HADOOP_WIKI);
assertInException(wrapped, "Host Details ");
assertRemoteDetailsIncluded(wrapped);
IOException wrapped = verifyExceptionClass(e, TestIOException.class);
assertEquals(null, wrapped.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertNull, with error text please

}

@Test
Expand Down