YARN-3400. [JDK 8] Build Failure due to unreported exceptions in RPCUtil (rkanter)

(cherry picked from commit 87130bf6b2)
This commit is contained in:
Robert Kanter 2015-03-26 11:00:20 -07:00
parent c035106c05
commit 6f0e864d61
2 changed files with 22 additions and 4 deletions

View File

@ -60,6 +60,9 @@ Release 2.8.0 - UNRELEASED
YARN-3383. AdminService should use "warn" instead of "info" to log exception YARN-3383. AdminService should use "warn" instead of "info" to log exception
when operation fails. (Li Lu via wangda) when operation fails. (Li Lu via wangda)
YARN-3400. [JDK 8] Build Failure due to unreported exceptions in
RPCUtil (rkanter)
Release 2.7.0 - UNRELEASED Release 2.7.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -70,6 +70,21 @@ public class RPCUtil {
} }
} }
private static <T extends YarnException> T instantiateYarnException(
Class<? extends T> cls, RemoteException re) throws RemoteException {
return instantiateException(cls, re);
}
private static <T extends IOException> T instantiateIOException(
Class<? extends T> cls, RemoteException re) throws RemoteException {
return instantiateException(cls, re);
}
private static <T extends RuntimeException> T instantiateRuntimeException(
Class<? extends T> cls, RemoteException re) throws RemoteException {
return instantiateException(cls, re);
}
/** /**
* Utility method that unwraps and returns appropriate exceptions. * Utility method that unwraps and returns appropriate exceptions.
* *
@ -94,17 +109,17 @@ public class RPCUtil {
// Assume this to be a new exception type added to YARN. This isn't // Assume this to be a new exception type added to YARN. This isn't
// absolutely correct since the RPC layer could add an exception as // absolutely correct since the RPC layer could add an exception as
// well. // well.
throw instantiateException(YarnException.class, re); throw instantiateYarnException(YarnException.class, re);
} }
if (YarnException.class.isAssignableFrom(realClass)) { if (YarnException.class.isAssignableFrom(realClass)) {
throw instantiateException( throw instantiateYarnException(
realClass.asSubclass(YarnException.class), re); realClass.asSubclass(YarnException.class), re);
} else if (IOException.class.isAssignableFrom(realClass)) { } else if (IOException.class.isAssignableFrom(realClass)) {
throw instantiateException(realClass.asSubclass(IOException.class), throw instantiateIOException(realClass.asSubclass(IOException.class),
re); re);
} else if (RuntimeException.class.isAssignableFrom(realClass)) { } else if (RuntimeException.class.isAssignableFrom(realClass)) {
throw instantiateException( throw instantiateRuntimeException(
realClass.asSubclass(RuntimeException.class), re); realClass.asSubclass(RuntimeException.class), re);
} else { } else {
throw re; throw re;