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,12 +105,16 @@ 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 {
// Ignore the last TC_RESET switch (buffer.readableBytes()) {
if (buffer.readableBytes() == 1 && case 0:
buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.skipBytes(1);
oin.close();
return null; return null;
case 1:
// Ignore the last TC_RESET
if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.skipBytes(1);
oin.close();
return null;
}
} }
Object decoded = decode(ctx, channel, buffer, state); Object decoded = decode(ctx, channel, buffer, state);