diff --git a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java index 943a3413c7..ba95fa80bd 100644 --- a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java @@ -51,8 +51,8 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer { } public DynamicChannelBuffer(ByteOrder endianness, int estimatedLength) { - if (estimatedLength <= 0) { - throw new IllegalArgumentException("estimatedLength"); + if (estimatedLength < 0) { + throw new IllegalArgumentException("estimatedLength: " + estimatedLength); } if (endianness == null) { throw new NullPointerException("endianness"); @@ -245,6 +245,9 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer { int newCapacity; if (capacity() == 0) { newCapacity = initialCapacity; + if (newCapacity == 0) { + newCapacity = 1; + } } else { newCapacity = capacity(); }