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 c0f1e9bd21
commit fbd6cc2503
3 changed files with 7 additions and 5 deletions

View File

@ -1043,11 +1043,12 @@ public class DefaultChannelPipeline implements ChannelPipeline {
* 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(Object msg) {
protected void onUnhandledInboundMessage(ChannelHandlerContext ctx, Object msg) {
try {
logger.debug(
"Discarded inbound message {} that reached at the tail of the pipeline. " +
"Please check your pipeline configuration.", msg);
"Please check your pipeline configuration. Discarded message pipeline : {}. Channel : {}.",
msg, ctx.pipeline().names(), ctx.channel());
} finally {
ReferenceCountUtil.release(msg);
}
@ -1136,7 +1137,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
((DefaultChannelPipeline) ctx.pipeline()).onUnhandledInboundMessage(msg);
((DefaultChannelPipeline) ctx.pipeline()).onUnhandledInboundMessage(ctx, msg);
}
@Override

View File

@ -28,6 +28,7 @@ import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelId;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelMetadata;
@ -870,7 +871,7 @@ public class EmbeddedChannel extends AbstractChannel {
}
@Override
protected void onUnhandledInboundMessage(Object msg) {
protected void onUnhandledInboundMessage(ChannelHandlerContext ctx, Object msg) {
handleInboundMessage(msg);
}
}

View File

@ -313,7 +313,7 @@ public class DefaultChannelPipelineTailTest {
}
@Override
protected void onUnhandledInboundMessage(Object msg) {
protected void onUnhandledInboundMessage(ChannelHandlerContext ctx, Object msg) {
MyChannel.this.onUnhandledInboundMessage(msg);
}