Fix a bug in AbstractByteBuf.writeZero() where the capacity is not auto-expanded

This commit is contained in:
Trustin Lee 2013-07-18 09:53:45 +09:00
parent fc7c950b08
commit f0a3f849f7

View File

@ -862,8 +862,7 @@ public abstract class AbstractByteBuf extends ByteBuf {
} }
@Override @Override
public int writeBytes(ScatteringByteChannel in, int length) public int writeBytes(ScatteringByteChannel in, int length) throws IOException {
throws IOException {
ensureWritable(length); ensureWritable(length);
int writtenBytes = setBytes(writerIndex, in, length); int writtenBytes = setBytes(writerIndex, in, length);
if (writtenBytes > 0) { if (writtenBytes > 0) {
@ -878,6 +877,7 @@ public abstract class AbstractByteBuf extends ByteBuf {
return this; return this;
} }
ensureWritable(length);
checkIndex(writerIndex, length); checkIndex(writerIndex, length);
int nLong = length >>> 3; int nLong = length >>> 3;