Skip to content

Commit 3961a92

Browse files
authored
core: Log any exception during panic because of exception
panic() calls a good amount of code, so it could get another exception. The SynchronizationContext is running on an arbitrary thread and we don't want to propagate this secondary exception up its stack (to be handled by its UncaughtExceptionHandler); it we wanted that we'd propagate the original exception. This second exception will only be seen in the logs; the first exception was logged and will be used to fail RPCs. Also related to http://yaqs/8493785598685872128 and b692b9d
1 parent 1958e42 commit 3961a92

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/java/io/grpc/internal/ManagedChannelImpl.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,12 @@ public void uncaughtException(Thread t, Throwable e) {
187187
Level.SEVERE,
188188
"[" + getLogId() + "] Uncaught exception in the SynchronizationContext. Panic!",
189189
e);
190-
panic(e);
190+
try {
191+
panic(e);
192+
} catch (Throwable anotherT) {
193+
logger.log(
194+
Level.SEVERE, "[" + getLogId() + "] Uncaught exception while panicking", anotherT);
195+
}
191196
}
192197
});
193198

0 commit comments

Comments
 (0)