Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception if Response has content #11093

Merged
merged 1 commit into from
Mar 21, 2021
Merged

Conversation

stuartwdouglas
Copy link
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
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
Contributor Author

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

@normanmaurer
Copy link
Member

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

@normanmaurer
Copy link
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
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
Member

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

@stuartwdouglas
Copy link
Contributor Author

Yes, it is good to go.

@normanmaurer
Copy link
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
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