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 com.google.common.base.Throwables;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
@ -56,7 +58,8 @@ public final class LogExceptionRunnable implements Runnable {
|
|||
task.run();
|
||||
} catch (Throwable 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());
|
||||
context.cancel(null);
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
stream.close(Status.fromThrowable(t), new Metadata());
|
||||
} catch (Error e) {
|
||||
stream.close(Status.fromThrowable(e), new Metadata());
|
||||
context.cancel(null);
|
||||
throw new RuntimeException(t);
|
||||
throw e;
|
||||
} finally {
|
||||
jumpListener.setListener(listener);
|
||||
}
|
||||
|
|
@ -487,9 +487,9 @@ public final class ServerImpl extends io.grpc.Server {
|
|||
} catch (RuntimeException e) {
|
||||
internalClose(Status.fromThrowable(e), new Metadata());
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
internalClose(Status.fromThrowable(t), new Metadata());
|
||||
throw new RuntimeException(t);
|
||||
} catch (Error e) {
|
||||
internalClose(Status.fromThrowable(e), new Metadata());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -505,9 +505,9 @@ public final class ServerImpl extends io.grpc.Server {
|
|||
} catch (RuntimeException e) {
|
||||
internalClose(Status.fromThrowable(e), new Metadata());
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
internalClose(Status.fromThrowable(t), new Metadata());
|
||||
throw new RuntimeException(t);
|
||||
} catch (Error e) {
|
||||
internalClose(Status.fromThrowable(e), new Metadata());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue