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) {
|
public DynamicChannelBuffer(ByteOrder endianness, int estimatedLength) {
|
||||||
if (estimatedLength <= 0) {
|
if (estimatedLength < 0) {
|
||||||
throw new IllegalArgumentException("estimatedLength");
|
throw new IllegalArgumentException("estimatedLength: " + estimatedLength);
|
||||||
}
|
}
|
||||||
if (endianness == null) {
|
if (endianness == null) {
|
||||||
throw new NullPointerException("endianness");
|
throw new NullPointerException("endianness");
|
||||||
|
@ -245,6 +245,9 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer {
|
||||||
int newCapacity;
|
int newCapacity;
|
||||||
if (capacity() == 0) {
|
if (capacity() == 0) {
|
||||||
newCapacity = initialCapacity;
|
newCapacity = initialCapacity;
|
||||||
|
if (newCapacity == 0) {
|
||||||
|
newCapacity = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
newCapacity = capacity();
|
newCapacity = capacity();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user