Fixed an issue: Netty-14 (IllegalArgumentException when creating a dynamic buffer with 0 estimatedLength)
* Allowed zero initial capacity * Made the exception message more specific
This commit is contained in:
parent
a7c73d2e52
commit
2d6cfe9af6
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user