Break the decode loop if decoder raises an exception to give a chance to close the connection to a user handler
- Fixes: #1161
This commit is contained in:
parent
b186342f52
commit
e3d10ad493
@ -82,12 +82,12 @@ public abstract class ByteToMessageDecoder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
ByteBuf in = ctx.inboundByteBuffer();
|
|
||||||
if (in.isReadable()) {
|
|
||||||
callDecode(ctx, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ByteBuf in = ctx.inboundByteBuffer();
|
||||||
|
if (in.isReadable()) {
|
||||||
|
callDecode(ctx, in);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx.nextInboundMessageBuffer().unfoldAndAdd(decodeLast(ctx, in))) {
|
if (ctx.nextInboundMessageBuffer().unfoldAndAdd(decodeLast(ctx, in))) {
|
||||||
ctx.fireInboundBufferUpdated();
|
ctx.fireInboundBufferUpdated();
|
||||||
}
|
}
|
||||||
@ -97,9 +97,9 @@ public abstract class ByteToMessageDecoder
|
|||||||
} else {
|
} else {
|
||||||
ctx.fireExceptionCaught(new DecoderException(t));
|
ctx.fireExceptionCaught(new DecoderException(t));
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
ctx.fireChannelInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.fireChannelInactive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void callDecode(ChannelHandlerContext ctx, ByteBuf in) {
|
protected void callDecode(ChannelHandlerContext ctx, ByteBuf in) {
|
||||||
@ -144,6 +144,8 @@ public abstract class ByteToMessageDecoder
|
|||||||
} else {
|
} else {
|
||||||
ctx.fireExceptionCaught(new DecoderException(t));
|
ctx.fireExceptionCaught(new DecoderException(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,13 +364,13 @@ public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
replayable.terminate();
|
|
||||||
ByteBuf in = cumulation;
|
|
||||||
if (in.isReadable()) {
|
|
||||||
callDecode(ctx, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
replayable.terminate();
|
||||||
|
ByteBuf in = cumulation;
|
||||||
|
if (in.isReadable()) {
|
||||||
|
callDecode(ctx, in);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx.nextInboundMessageBuffer().unfoldAndAdd(decodeLast(ctx, replayable))) {
|
if (ctx.nextInboundMessageBuffer().unfoldAndAdd(decodeLast(ctx, replayable))) {
|
||||||
ctx.fireInboundBufferUpdated();
|
ctx.fireInboundBufferUpdated();
|
||||||
}
|
}
|
||||||
@ -383,9 +383,9 @@ public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
|
|||||||
} else {
|
} else {
|
||||||
ctx.fireExceptionCaught(new DecoderException(t));
|
ctx.fireExceptionCaught(new DecoderException(t));
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
ctx.fireChannelInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.fireChannelInactive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -458,6 +458,8 @@ public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
|
|||||||
} else {
|
} else {
|
||||||
ctx.fireExceptionCaught(new DecoderException(t));
|
ctx.fireExceptionCaught(new DecoderException(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user