#7285 Improved "Discarded inbound message" warning (#9286)

Motivation:

On servers with many pipelines or dynamic pipelines, it is easy for end user to make mistake during pipeline configuration. Current message:

`Discarded inbound message PooledUnsafeDirectByteBuf(ridx: 0, widx: 2, cap: 2) that reached at the tail of the pipeline. Please check your pipeline configuration.`

Is not always meaningful and doesn't allow to find the wrong pipeline quickly.

Modification:

Added additional log placeholder that identifies pipeline handlers and channel info. This will allow for the end users quickly find the problem pipeline.

Result:

Meaningful warning when the message reaches the end of the pipeline. Fixes #7285
This commit is contained in:
Dmitriy Dumanskiy 2019-07-01 21:38:59 +03:00 committed by Norman Maurer
parent f8c1f350db
commit 5ded050f7b
1 changed files with 14 additions and 1 deletions

View File

@ -1198,6 +1198,19 @@ public class DefaultChannelPipeline implements ChannelPipeline {
}
}
/**
* Called once a message hit the end of the {@link ChannelPipeline} without been handled by the user
* in {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)}. This method is responsible
* to call {@link ReferenceCountUtil#release(Object)} on the given msg at some point.
*/
protected void onUnhandledInboundMessage(ChannelHandlerContext ctx, Object msg) {
onUnhandledInboundMessage(msg);
if (logger.isDebugEnabled()) {
logger.debug("Discarded message pipeline : {}. Channel : {}.",
ctx.pipeline().names(), ctx.channel());
}
}
/**
* Called once the {@link ChannelInboundHandler#channelReadComplete(ChannelHandlerContext)} event hit
* the end of the {@link ChannelPipeline}.
@ -1291,7 +1304,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
onUnhandledInboundMessage(msg);
onUnhandledInboundMessage(ctx, msg);
}
@Override