Skip to content

12.0.x: Rework consumeAvailable() mechanism#14007

Merged
lorban merged 6 commits intojetty-12.0.xfrom
enhancement/12.0.x/channelstate-consumeall
Nov 17, 2025
Merged

12.0.x: Rework consumeAvailable() mechanism#14007
lorban merged 6 commits intojetty-12.0.xfrom
enhancement/12.0.x/channelstate-consumeall

Conversation

@lorban
Copy link
Contributor

@lorban lorban commented Nov 10, 2025

Started with a fix for a comment detailing the consumeAvailable() behavior that is partially incorrect, ended up reworking the consumeAvailable() mechanism.

See #13934 (comment)

See #14026 for the 12.1.x version of this PR.

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban requested a review from gregw November 10, 2025 11:17
@lorban lorban self-assigned this Nov 10, 2025
@lorban lorban moved this to 👀 In review in Jetty 12.0.31 Nov 10, 2025
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'm a bit more concerned about this now, as I didn't realise that HttpStreamOverHttp1#consumeAvailable made the connection non-persistent.

If this is the case, it is a little bit redundant as we have the method org.eclipse.jetty.server.ResponseUtils#ensureConsumeAvailableOrNotPersistent, which does a much better job of being non persistent.

I think we need to look a little closer before moving on, and maybe document a b it more

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban
Copy link
Contributor Author

lorban commented Nov 11, 2025

I'm a bit more concerned about this now, as I didn't realise that HttpStreamOverHttp1#consumeAvailable made the connection non-persistent.

If this is the case, it is a little bit redundant as we have the method org.eclipse.jetty.server.ResponseUtils#ensureConsumeAvailableOrNotPersistent, which does a much better job of being non persistent.

I think we need to look a little closer before moving on, and maybe document a b it more

ResponseUtils#ensureConsumeAvailableOrNotPersistent works at the Request level, so eventually that work is delegated to HttpStream#consumeAvailable.

Out of curiosity, I tried disabling the ensureNotPersistent call from ensureConsumeAvailableOrNotPersistent and that didn't break a single test, so I'm tempted to believe ResponseUtils#ensureConsumeAvailableOrNotPersistent could be replaced with Request#consumeAvailable, and ResponseUtils removed.

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban
Copy link
Contributor Author

lorban commented Nov 11, 2025

I pushed the removal of ResponseUtils and added the missing javadoc.

How does that look?

@lorban lorban requested a review from gregw November 11, 2025 15:11
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban
Copy link
Contributor Author

lorban commented Nov 12, 2025

@gregw I've reworked the whole consumeAvailable() mechanism to get rid of ResponseUtils, and fixed ServletCoreRequest.consumeAvailable() to make sure it never blocks even when the servlet request is wrapped.

@lorban lorban changed the title Fix comment about consumeAll() behavior in ChannelState Rework consumeAvailable() mechanism Nov 12, 2025
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
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.

Thinking on this one for a day...

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.

This is good. The HttpGenerator does all the headers required.

@lorban lorban changed the title Rework consumeAvailable() mechanism 12.0.x: Rework consumeAvailable() mechanism Nov 13, 2025
@lorban lorban merged commit 7addd31 into jetty-12.0.x Nov 17, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Jetty 12.0.31 Nov 17, 2025
@lorban lorban deleted the enhancement/12.0.x/channelstate-consumeall branch November 17, 2025 08:07
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.

2 participants