Fix capacity check bug affecting offheap buffers

This commit is contained in:
Jake Luciani 2014-05-09 16:32:43 -04:00 committed by Norman Maurer
parent e29f8231aa
commit d547b5d51d
3 changed files with 5 additions and 2 deletions

View File

@ -274,7 +274,7 @@ final class PooledDirectByteBuf extends PooledByteBuf<ByteBuffer> {
@Override
public ByteBuf setBytes(int index, ByteBuffer src) {
checkIndex(index);
checkIndex(index, src.remaining());
ByteBuffer tmpBuf = internalNioBuffer();
if (src == tmpBuf) {
src = src.duplicate();

View File

@ -278,7 +278,7 @@ final class PooledUnsafeDirectByteBuf extends PooledByteBuf<ByteBuffer> {
@Override
public ByteBuf setBytes(int index, ByteBuffer src) {
checkIndex(index);
checkIndex(index, src.remaining());
ByteBuffer tmpBuf = internalNioBuffer();
if (src == tmpBuf) {
src = src.duplicate();

View File

@ -16,6 +16,7 @@
package io.netty.buffer;
import io.netty.util.CharsetUtil;
import io.netty.util.internal.EmptyArrays;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
@ -163,6 +164,8 @@ public abstract class AbstractByteBufTest {
buffer.writerIndex(0);
buffer.readerIndex(0);
buffer.writerIndex(CAPACITY);
buffer.writeBytes(ByteBuffer.wrap(EmptyArrays.EMPTY_BYTES));
}
@Test(expected = IndexOutOfBoundsException.class)