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

Fixes #12122 - NPE in HttpReceiver.responseContentAvailable(). #12123

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Aug 1, 2024

Now also the HttpReceiver.responseContentAvailable() is serialized, so that the access to this.contentSource is serialized with failure, and protected by a call to exchange.isResponseCompleteOrTerminated().

Before, it was possible that a thread failed the response, nulling out this.contentSource, while another thread was just about to call responseContentAvailable() -- this was the case for HTTP/2 in particular, where content is notified asynchronously, rather than being created by a call to ContentSource.read().

Now also the HttpReceiver.responseContentAvailable() is serialized, so that the access to `this.contentSource` is serialized with failure, and protected by a call to `exchange.isResponseCompleteOrTerminated()`.

Before, it was possible that a thread failed the response, nulling out `this.contentSource`, while another thread was just about to call `responseContentAvailable()` -- this was the case for HTTP/2 in particular, where content is notified asynchronously, rather than being created by a call to `ContentSource.read()`.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from gregw and lorban August 1, 2024 14:51
@sbordet sbordet linked an issue Aug 1, 2024 that may be closed by this pull request
@wendigo
Copy link

wendigo commented Aug 1, 2024

@sbordet can you stage artifacts for me to test?

firoj0

This comment was marked as spam.

@jetty jetty deleted a comment from firoj0 Aug 1, 2024
@jetty jetty deleted a comment from firoj0 Aug 1, 2024
@jetty jetty deleted a comment from firoj0 Aug 1, 2024
@jetty jetty deleted a comment from firoj0 Aug 1, 2024
@jetty jetty deleted a comment from firoj0 Aug 1, 2024
@wendigo
Copy link

wendigo commented Aug 3, 2024

I can confirm that this change fixes the issue that we've seen in our benchmarks while running with HTTP/2

* This method directly invokes the demand callback, assuming the caller
* is already serialized with other events.
*/
protected void responseContentAvailable()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this method be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is called from other places when it's known that there is no need to serialize.

@sbordet sbordet requested a review from lorban August 7, 2024 07:26
lorban
lorban previously approved these changes Aug 7, 2024
Added test case.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet merged commit d0ea445 into jetty-12.0.x Aug 7, 2024
10 checks passed
@sbordet sbordet deleted the fix/jetty-12.0.x/12122/httpreceiver-npe branch August 7, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

NPE in HttpReceiver.responseContentAvailable()
5 participants