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

Issue #12266 - InvocationType improvements and cleanups. #12596

Merged
merged 24 commits into from
Jan 7, 2025

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Nov 29, 2024

This is the work for the client-side.

Now the InvocationType can be specified at the HttpClientTransport level, or at the ClientConnectionFactory.Info level (for the dynamic transport).

Wired the InvocationType also for Response.ContentSourceListener, so that for applications that read response content using Content.Source and specify an InvocationType to demand(Runnable), the implementation will honor it.

This is the work for the client-side.

Now the `InvocationType` can be specified at the `HttpClientTransport` level, or at the `ClientConnectionFactory.Info` level (for the dynamic transport).

Wired the `InvocationType` also for `Response.ContentSourceListener`, so that for applications that read response content using `Content.Source` and specify an `InvocationType` to `demand(Runnable)`, the implementation will honor it.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from gregw and lorban November 29, 2024 14:10
@sbordet sbordet linked an issue Nov 29, 2024 that may be closed by this pull request
Simplified retrieval of InvocationType, now only available from the HttpClientTransport.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…case of content not yet arrived.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Before, `Stream.Listener.onHeaders()` was assuming that the headers were processed synchronously.
Now, `HttpReceiverOverHTTP2` process them asynchronously, with a task that declares an invocation type.
This was causing a race between the task and the code present after the call to `onHeaders()`.

Introduced `Stream.Listener.onHeaders(Stream, HeadersFrame, Callback)` to allow asynchronous processing of `HeadersFrame`s.

Optimised `HttpReceiver.responseHeaders()` to avoid creating the `Content.Source` if there is no content.

Fixed `IteratingCallback` and `HTTP2Flusher` to use `tryLock()` in `toString()` to avoid deadlocks.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…type-cleanups'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…type-cleanups'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet added this to the ! milestone Dec 12, 2024
…type-cleanups'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…type-cleanups'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Fixed reset race in HTTP2Stream.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…type-cleanups'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
For HTTP/2, the response may have arrived, but the exchange failed (due to the request being failed); in this case, we want to notify an UpgradeException, not a generic Exception.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested a review from lorban January 6, 2025 15:18
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@lorban lorban self-requested a review January 6, 2025 16:47
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

I've a couple of minor niggles... but I've approved anyway.

// Ask the InvocationType to the Content.Source, where applications
// have set it there using Content.Source.demand(Runnable).
Invocable.InvocationType invocationType = Invocable.getInvocationType(contentSource);
Runnable demandCallback = Invocable.from(invocationType, () -> onContentSource(response, contentSource));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can improve Invocable.from so that for any Runnable passed in that is not Invocable, it will not wrap with a ReadyTask if the type is BLOCKING.

@Override
public InvocationType getInvocationType()
{
return Invocable.getInvocationType(contentSource);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worthwhile working this out once when the contentSource is set?
Probably not... but maybe???

@Override
public InvocationType getInvocationType()
{
return Invocable.getInvocationType(source);
Copy link
Contributor

Choose a reason for hiding this comment

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

source is final, so perhaps work this out in the constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't make it a constant because Content.Source delegates the InvocationType to the demand callback that may change across invocations of demand(Runnable) -- although admittedly rare.

@sbordet sbordet merged commit 4939a8b into jetty-12.1.x Jan 7, 2025
8 of 10 checks passed
@sbordet sbordet deleted the fix/jetty-12.1.x/client-invocationtype-cleanups branch January 7, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

InvocationType improvements and cleanups
3 participants