Return null in HttpPostRequestEncoder#9352
Merged
normanmaurer merged 3 commits intonetty:4.1from Jul 16, 2019
Merged
Conversation
Motivation: If the encoded value of a form element happens to exactly hit the chunk limit (8096 bytes), the post request encoder will throw a NullPointerException. Modifications: Catch the null case and return. Result: No NPE.
normanmaurer
requested changes
Jul 11, 2019
|
|
||
| HttpRequest finalRequest = encoder.finalizeRequest(); | ||
|
|
||
| ch.writeOutbound(finalRequest); |
Member
There was a problem hiding this comment.
add assert for return value
| HttpRequest finalRequest = encoder.finalizeRequest(); | ||
|
|
||
| ch.writeOutbound(finalRequest); | ||
| ch.writeOutbound(encoder); |
Member
There was a problem hiding this comment.
add assert for return value
|
|
||
| ch.writeOutbound(finalRequest); | ||
| ch.writeOutbound(encoder); | ||
| ch.flushOutbound(); |
Member
There was a problem hiding this comment.
call ch.finish() and assert return value .
|
|
||
| @Test | ||
| public void testEncodeChunkedContent() throws Exception { | ||
| EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler()); |
Member
There was a problem hiding this comment.
why is the ChunkedWriteHandler needed ?
Contributor
Author
There was a problem hiding this comment.
That was the closest thing I could find to the logic in Finagle. I just changed it though.
|
Can one of the admins verify this patch? |
normanmaurer
requested changes
Jul 12, 2019
| assertNotNull(encoder.finalizeRequest()); | ||
|
|
||
| while (!encoder.isEndOfInput()) { | ||
| encoder.readChunk((ByteBufAllocator) null); |
Member
There was a problem hiding this comment.
you need to also release the HttpContent returned by this method as otherwise the test will leak memory:
encoder.readChunk(...).release()
Member
|
@netty-bot test this please |
normanmaurer
approved these changes
Jul 16, 2019
Member
|
@emlittleworth thanks a lot! |
normanmaurer
pushed a commit
that referenced
this pull request
Jul 16, 2019
Motivation: If the encoded value of a form element happens to exactly hit the chunk limit (8096 bytes), the post request encoder will throw a NullPointerException. Modifications: Catch the null case and return. Result: No NPE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
If the encoded value of a form element happens to exactly hit the chunk limit (8096 bytes), the post request encoder will throw a NullPointerException.
Modification:
Catch the null case and return.
Result:
Fixes #9351.