mirror of https://github.com/grpc/grpc-java.git
core: Avoid wrapping Errors in RuntimeException
This commit is contained in:
parent
f25f55a76f
commit
d394cef775
|
|
@ -33,6 +33,8 @@ package io.grpc.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
@ -56,7 +58,8 @@ public final class LogExceptionRunnable implements Runnable {
|
||||||
task.run();
|
task.run();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.log(Level.SEVERE, "Exception while executing runnable " + task, t);
|
log.log(Level.SEVERE, "Exception while executing runnable " + task, t);
|
||||||
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
|
Throwables.propagateIfPossible(t);
|
||||||
|
throw new AssertionError(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -364,10 +364,10 @@ public final class ServerImpl extends io.grpc.Server {
|
||||||
stream.close(Status.fromThrowable(e), new Metadata());
|
stream.close(Status.fromThrowable(e), new Metadata());
|
||||||
context.cancel(null);
|
context.cancel(null);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable t) {
|
} catch (Error e) {
|
||||||
stream.close(Status.fromThrowable(t), new Metadata());
|
stream.close(Status.fromThrowable(e), new Metadata());
|
||||||
context.cancel(null);
|
context.cancel(null);
|
||||||
throw new RuntimeException(t);
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
jumpListener.setListener(listener);
|
jumpListener.setListener(listener);
|
||||||
}
|
}
|
||||||
|
|
@ -487,9 +487,9 @@ public final class ServerImpl extends io.grpc.Server {
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
internalClose(Status.fromThrowable(e), new Metadata());
|
internalClose(Status.fromThrowable(e), new Metadata());
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable t) {
|
} catch (Error e) {
|
||||||
internalClose(Status.fromThrowable(t), new Metadata());
|
internalClose(Status.fromThrowable(e), new Metadata());
|
||||||
throw new RuntimeException(t);
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -505,9 +505,9 @@ public final class ServerImpl extends io.grpc.Server {
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
internalClose(Status.fromThrowable(e), new Metadata());
|
internalClose(Status.fromThrowable(e), new Metadata());
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable t) {
|
} catch (Error e) {
|
||||||
internalClose(Status.fromThrowable(t), new Metadata());
|
internalClose(Status.fromThrowable(e), new Metadata());
|
||||||
throw new RuntimeException(t);
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue