Log all exceptions thrown at the end of the pipeline

The RelayHandler is installed at the end of a channel pipeline (both frontend and backend). If it does not log the exception, it will be regarded and unhandled exception, which shows up in logs, but does not log the corresponding channel.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208984756
This commit is contained in:
jianglai 2018-08-16 08:05:30 -07:00
parent 8a1c99e22b
commit 782643ce33

View file

@ -78,10 +78,11 @@ public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
if (cause instanceof OverQuotaException) { if (cause instanceof OverQuotaException) {
logger.atWarning().withCause(cause).log( logger.atWarning().withCause(cause).log(
"Channel %s closed due to quota exceeded.", ctx.channel()); "Channel %s closed due to quota exceeded.", ctx.channel());
ChannelFuture unusedFuture = ctx.close();
} else { } else {
ctx.fireExceptionCaught(cause); logger.atWarning().withCause(cause).log(
"Channel %s closed due to unexpected exception.", ctx.channel());
} }
ChannelFuture unusedFuture = ctx.close();
} }
public static void writeToRelayChannel( public static void writeToRelayChannel(