Fixed test failure

This commit is contained in:
Trustin Lee 2009-06-04 06:15:19 +00:00
parent 02ba3b553a
commit df06536818

View File

@ -89,7 +89,7 @@ public class CompatibleObjectDecoder extends ReplayingDecoder<CompatibleObjectDe
protected Object decode( protected Object decode(
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, CompatibleObjectDecoderState state) throws Exception { ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, CompatibleObjectDecoderState state) throws Exception {
bin.switchStream(new ChannelBufferInputStream(buffer)); bin.switchStream(new ChannelBufferInputStream(buffer));
System.out.println(buffer);
switch (state) { switch (state) {
case READ_HEADER: case READ_HEADER:
oin = newObjectInputStream(bin); oin = newObjectInputStream(bin);
@ -105,13 +105,17 @@ public class CompatibleObjectDecoder extends ReplayingDecoder<CompatibleObjectDe
protected Object decodeLast(ChannelHandlerContext ctx, Channel channel, protected Object decodeLast(ChannelHandlerContext ctx, Channel channel,
ChannelBuffer buffer, CompatibleObjectDecoderState state) ChannelBuffer buffer, CompatibleObjectDecoderState state)
throws Exception { throws Exception {
switch (buffer.readableBytes()) {
case 0:
return null;
case 1:
// Ignore the last TC_RESET // Ignore the last TC_RESET
if (buffer.readableBytes() == 1 && if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.skipBytes(1); buffer.skipBytes(1);
oin.close(); oin.close();
return null; return null;
} }
}
Object decoded = decode(ctx, channel, buffer, state); Object decoded = decode(ctx, channel, buffer, state);
oin.close(); oin.close();