protected InvocationResult invokeInternal(Method method, Object[] args) throws Throwable {
    InvocationResult result;
    try {
      Object methodResult = method.invoke(base, args);
      result = new InvocationResult(true, methodResult, null);
    } catch (UndeclaredThrowableException e) {
      throw e.getCause();
    } catch (InvocationTargetException e) {
      if (e.getCause() instanceof HiveSQLException) {
        HiveSQLException hiveExc = (HiveSQLException) e.getCause();
        Throwable cause = hiveExc.getCause();
        if ((cause instanceof TApplicationException) ||
          (cause instanceof TProtocolException) ||
          (cause instanceof TTransportException)) {
          result =  new InvocationResult(false, null, hiveExc);
        } else {
          throw hiveExc;
        }
      } else {
        throw e.getCause();
      }
    }
    return result;
  }
RetryingThriftCLIServiceClient. Creates a proxy for a CLIServiceClient
implementation and retries calls to it on failure.
service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java