Fixed issue: NETTY-164 ReplayingDecoderBuffer.readableBytes() and capacity() should not return Integer.MAX_VALUE if the connection is closed.
* Added ReplayingDecoderBuffer.terminate(), which makes readableBytes() and capacity() to return an ordinary value instead of Integer.MAX_VALUE
This commit is contained in:
parent
2100462235
commit
3acda248c1
@ -455,6 +455,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
private void cleanup(ChannelHandlerContext ctx, ChannelStateEvent e)
|
||||
throws Exception {
|
||||
ChannelBuffer cumulation = cumulation(ctx);
|
||||
replayable.terminate();
|
||||
try {
|
||||
if (cumulation.readable()) {
|
||||
// Make sure all data was read before notifying a closed channel.
|
||||
|
@ -46,13 +46,22 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
private static final Error REPLAY = new ReplayError();
|
||||
|
||||
private final ChannelBuffer buffer;
|
||||
private boolean terminated;
|
||||
|
||||
ReplayingDecoderBuffer(ChannelBuffer buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
void terminate() {
|
||||
terminated = true;
|
||||
}
|
||||
|
||||
public int capacity() {
|
||||
return Integer.MAX_VALUE;
|
||||
if (terminated) {
|
||||
return buffer.capacity();
|
||||
} else {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@ -210,7 +219,11 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
||||
}
|
||||
|
||||
public int readableBytes() {
|
||||
return Integer.MAX_VALUE - buffer.readerIndex();
|
||||
if (terminated) {
|
||||
return buffer.readableBytes();
|
||||
} else {
|
||||
return Integer.MAX_VALUE - buffer.readerIndex();
|
||||
}
|
||||
}
|
||||
|
||||
public byte readByte() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user