-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
NullPointerException in HttpPostRequestEncoder #5478
Copy link
Copy link
Closed
Description
Hello,
There is a bug in the nextChunk() algorithm of the HttpPostRequestEncoder. When chunking a big request or multipart data, if the size of the resulting query is a multiple of the chunk size, isLastChunkSent is not set to true at the end, resulting in a NullPointerException.
This bug is present in version 3.10 as well as 4.x
Here is a unitest that shows this problem:
@Test
public void testNpe() throws Exception {
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.POST, "http://localhost");
HttpPostRequestEncoder encoder = new HttpPostRequestEncoder(request, true);
int length = 7943;
char[] array = new char[length];
Arrays.fill(array, 'a');
String longText = new String(array);
encoder.addBodyAttribute("foo", longText);
encoder.finalizeRequest();
while (! encoder.isEndOfInput()) {
encoder.readChunk((ByteBufAllocator) null);
}
}Reactions are currently unavailable