merge TEZ-731 from trunk. RPCUtil.unwrapAndThrowException should unwrap remote RuntimeExceptions. Contributed by Zhijie Shen.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1492001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9cc1150be1
commit
ed2576ac0d
|
@ -292,6 +292,9 @@ Release 2.1.0-beta - UNRELEASED
|
||||||
YARN-737. Throw some specific exceptions directly instead of wrapping them
|
YARN-737. Throw some specific exceptions directly instead of wrapping them
|
||||||
in YarnException. (Jian He via sseth)
|
in YarnException. (Jian He via sseth)
|
||||||
|
|
||||||
|
YARN-731. RPCUtil.unwrapAndThrowException should unwrap remote
|
||||||
|
RuntimeExceptions. (Zhijie Shen via sseth)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
YARN-512. Log aggregation root directory check is more expensive than it
|
YARN-512. Log aggregation root directory check is more expensive than it
|
||||||
|
|
|
@ -101,6 +101,9 @@ public class RPCUtil {
|
||||||
} else if (IOException.class.isAssignableFrom(realClass)) {
|
} else if (IOException.class.isAssignableFrom(realClass)) {
|
||||||
throw instantiateException(realClass.asSubclass(IOException.class),
|
throw instantiateException(realClass.asSubclass(IOException.class),
|
||||||
re);
|
re);
|
||||||
|
} else if (RuntimeException.class.isAssignableFrom(realClass)) {
|
||||||
|
throw instantiateException(
|
||||||
|
realClass.asSubclass(RuntimeException.class), re);
|
||||||
} else {
|
} else {
|
||||||
throw re;
|
throw re;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +113,9 @@ public class RPCUtil {
|
||||||
} else if (cause instanceof IOException) {
|
} else if (cause instanceof IOException) {
|
||||||
// RPC Client exception.
|
// RPC Client exception.
|
||||||
throw (IOException) cause;
|
throw (IOException) cause;
|
||||||
|
} else if (cause instanceof RuntimeException) {
|
||||||
|
// RPC RuntimeException
|
||||||
|
throw (RuntimeException) cause;
|
||||||
} else {
|
} else {
|
||||||
// Should not be generated.
|
// Should not be generated.
|
||||||
throw new IOException(se);
|
throw new IOException(se);
|
||||||
|
|
|
@ -64,6 +64,12 @@ public class TestRPCUtil {
|
||||||
verifyRemoteExceptionUnwrapping(exception, exception.getName());
|
verifyRemoteExceptionUnwrapping(exception, exception.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoteRuntimeExceptionUnwrapping() {
|
||||||
|
Class<? extends Throwable> exception = NullPointerException.class;
|
||||||
|
verifyRemoteExceptionUnwrapping(exception, exception.getName());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnexpectedRemoteExceptionUnwrapping() {
|
public void testUnexpectedRemoteExceptionUnwrapping() {
|
||||||
// Non IOException, YarnException thrown by the remote side.
|
// Non IOException, YarnException thrown by the remote side.
|
||||||
|
@ -110,6 +116,23 @@ public class TestRPCUtil {
|
||||||
Assert.assertTrue(t.getMessage().contains(message));
|
Assert.assertTrue(t.getMessage().contains(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRPCRuntimeExceptionUnwrapping() {
|
||||||
|
String message = "RPCRuntimeExceptionUnwrapping";
|
||||||
|
RuntimeException re = new NullPointerException(message);
|
||||||
|
ServiceException se = new ServiceException(re);
|
||||||
|
|
||||||
|
Throwable t = null;
|
||||||
|
try {
|
||||||
|
RPCUtil.unwrapAndThrowException(se);
|
||||||
|
} catch (Throwable thrown) {
|
||||||
|
t = thrown;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertTrue(NullPointerException.class.isInstance(t));
|
||||||
|
Assert.assertTrue(t.getMessage().contains(message));
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyRemoteExceptionUnwrapping(
|
private void verifyRemoteExceptionUnwrapping(
|
||||||
Class<? extends Throwable> expectedLocalException,
|
Class<? extends Throwable> expectedLocalException,
|
||||||
String realExceptionClassName) {
|
String realExceptionClassName) {
|
||||||
|
|
Loading…
Reference in New Issue