8000 avoid writing 2 new lines without content · chakra-coder/async-http-client@2f0330a · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f0330a

Browse files
committed
avoid writing 2 new lines without content
Fix the following error happening on the server side: java.lang.NullPointerException: null at o 8000 rg.jboss.netty.handler.codec.http.HttpClientCodec$Decoder.isContentAlwaysEmpty(HttpClientCodec.java:179) ~[netty-3.9.2.Final.jar:na]
1 parent 1aa0d6e commit 2f0330a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/com/ning/http/client/providers/netty/FeedableBodyGenerator.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ public long read(final ByteBuffer buffer) throws IOException {
7575
}
7676
int capacity = buffer.remaining() - 10; 8000 // be safe (we'll have to add size, ending, etc.)
7777
int size = Math.min(nextPart.buffer.remaining(), capacity);
78-
buffer.put(getBytes(Integer.toHexString(size)));
79-
buffer.put(END_PADDING);
80-
for (int i = 0; i < size; i++) {
81-
buffer.put(nextPart.buffer.get());
78+
if (size != 0) {
79+
buffer.put(getBytes(Integer.toHexString(size)));
80+
buffer.put(END_PADDING);
81+
for (int i = 0; i < size; i++) {
82+
buffer.put(nextPart.buffer.get());
83+
}
84+
buffer.put(END_PADDING);
8285
}
83-
buffer.put(END_PADDING);
8486
if (!nextPart.buffer.hasRemaining()) {
8587
if (nextPart.isLast) {
8688
finishState = CLOSING;

0 commit comments

Comments
 (0)
0