Calling clear is wrong. See #396

This commit is contained in:
Norman Maurer 2012-06-17 20:28:47 +02:00
parent 7412c371f2
commit 127e9c1d1e

View File

@ -143,9 +143,8 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
void read() { void read() {
ByteBuf byteBuf = pipeline().inboundByteBuffer(); ByteBuf byteBuf = pipeline().inboundByteBuffer();
expandReadBuffer(byteBuf); expandReadBuffer(byteBuf);
// Get a ByteBuffer view on the ByteBuf
// Get a ByteBuffer view on the ByteBuf and clear it before try to read ByteBuffer buffer = byteBuf.nioBuffer(byteBuf.writerIndex(), byteBuf.writableBytes());
ByteBuffer buffer = (ByteBuffer) byteBuf.nioBuffer(byteBuf.writerIndex(), byteBuf.writableBytes()).clear();
javaChannel().read(buffer, this, READ_HANDLER); javaChannel().read(buffer, this, READ_HANDLER);
} }
@ -255,7 +254,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
// This is needed as the ByteBuffer and the ByteBuf does not share // This is needed as the ByteBuffer and the ByteBuf does not share
// each others index // each others index
final ByteBuf byteBuf = pipeline.inboundByteBuffer(); final ByteBuf byteBuf = pipeline.inboundByteBuffer();
byteBuf.writerIndex(byteBuf.writerIndex() + result); byteBuf.writerIndex(byteBuf.writerIndex() + localReadAmount);
read = true; read = true;