Skip to content

Fix exception if Response has content#11093

Merged
normanmaurer merged 1 commit into
netty:masterfrom
stuartwdouglas:11092
Mar 21, 2021
Merged

Fix exception if Response has content#11093
normanmaurer merged 1 commit into
netty:masterfrom
stuartwdouglas:11092

Conversation

@stuartwdouglas
Copy link
Copy Markdown
Contributor

Motivation:

If compression is enabled and the HttpResponse also
implements HttpContent (but not LastHttpContent) then
the buffer will be freed to eagerly.

Modification:

I retain the buffer the same way that is done for the LastHttpContent case.

Note that there is another suspicious looking call a few lines above (if beginEncode returns null). I am not sure if this should also be retained.

Result:

Fixes #11092

@stuartwdouglas
Copy link
Copy Markdown
Contributor Author

@normanmaurer in the pass through case the message is added to out without being retained: https://github.com/netty/netty/blob/12fbc8320fb935ed7a8de08729de9bc41aadfdbf/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java#L146

but then when it runs the PASS_THROUGH branch it is added again and is retained:

https://github.com/netty/netty/blob/12fbc8320fb935ed7a8de08729de9bc41aadfdbf/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java#L216

Is it intentional to have the same object in the out list twice?

@stuartwdouglas
Copy link
Copy Markdown
Contributor Author

I am not sure how these failures could be related, is this a known issue?

@normanmaurer
Copy link
Copy Markdown
Member

@stuartwdouglas imho have the same object in the out list twice is not expected

@normanmaurer
Copy link
Copy Markdown
Member

@stuartwdouglas yeah these failures are not related... not sure yet why these popped up.

If compression is enabled and the HttpResponse also
implements HttpContent (but not LastHttpContent) then
the buffer will be freed to eagerly.

Fixes netty#11092
@stuartwdouglas
Copy link
Copy Markdown
Contributor Author

Turns out I misread the code. I think it is fine, and there is no need to retain it because if it is pass through there is no body anyway.

@normanmaurer
Copy link
Copy Markdown
Member

@stuartwdouglas ok... so you say this PR is ready to go then ?

@stuartwdouglas
Copy link
Copy Markdown
Contributor Author

Yes, it is good to go.

@normanmaurer
Copy link
Copy Markdown
Member

The test failure is fixed by #11102 and not related

@normanmaurer normanmaurer added this to the 4.1.61.Final milestone Mar 21, 2021
@normanmaurer normanmaurer merged commit 56703b9 into netty:master Mar 21, 2021
normanmaurer pushed a commit that referenced this pull request Mar 21, 2021
Motivation:

If compression is enabled and the HttpResponse also
implements HttpContent (but not LastHttpContent) then
the buffer will be freed to eagerly.

Modification:

I retain the buffer the same way that is done for the LastHttpContent case.

Note that there is another suspicious looking call a few lines above (if beginEncode returns null). I am not sure if this should also be retained.

Result:

Fixes #11092
@normanmaurer
Copy link
Copy Markdown
Member

@stuartwdouglas thanks a lot

raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
Motivation:

If compression is enabled and the HttpResponse also
implements HttpContent (but not LastHttpContent) then
the buffer will be freed to eagerly.

Modification:

I retain the buffer the same way that is done for the LastHttpContent case.

Note that there is another suspicious looking call a few lines above (if beginEncode returns null). I am not sure if this should also be retained.

Result:

Fixes netty#11092
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants