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

EagerContentHandler. #9051 #12077

Merged
merged 84 commits into from
Nov 17, 2024
Merged

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Jul 23, 2024

Fix #9051 with EagerContentHandler to replace DelayedHandler

The make the EagerContentHandler.RetainedContentLoader work efficiently this PR adjusted the buffering strategy of h1, h2 and h3 to keep and reuse a retained buffer until it is mostly full.

Also fixed several bugs in XmlConfiguration:

  • A Set could not be used with a builder style method (kind of missing feature more than a bug)
  • If a property element was used in a Set it could only be a string and the type element was ignored.
  • When trying to find a native match, the vClass local variable was overwritten with the native TYPE being tried. This affected subsequent match attempts using the wrong vClass

@gregw
Copy link
Contributor Author

gregw commented Jul 23, 2024

@sbordet @lorban Your thoughts on doing this? If you think it is a good idea, can you contribute the h2 and h3 delayed dispatch handling to this branch.
I will then change the DelayedHandler to only be for delaying to read the entire content (buffering to disk or parsing multi-part or form content).

@lorban
Copy link
Contributor

lorban commented Jul 23, 2024

Implementation-wise, this looks alright assuming the same logic can be replicated in H2/H3 (but I doubt this is going to be troublesome).

But could you summarize what benefits/drawbacks this has over the existing DelayedHandler both for clarity and posterity?

@gregw
Copy link
Contributor Author

gregw commented Jul 23, 2024

@lorban wrote:

could you summarize what benefits/drawbacks this has over the existing DelayedHandler both for clarity and posterity?

The DelayedHandler is not able to truly delay the dispatch to the next handler without an execute. This is because, unlike the handle call, the demand callback is serialized with other demand/write callbacks. So if a demand callback is used to call the next handler handle method, it can dead lock if blocks waiting on a demand/write callback. Thus we need to dispatch, which kind of defeats the whole purpose of avoiding scheduling delays on the initial dispatch without content.

@gregw
Copy link
Contributor Author

gregw commented Jul 26, 2024

@sbordet @lorban Can you take this one on

@gregw
Copy link
Contributor Author

gregw commented Aug 6, 2024

I've also taken the opportunity to cleanup lots of deprecation and TODOs in HttpConnection

@gregw
Copy link
Contributor Author

gregw commented Aug 7, 2024

@lachlan-roberts Can you take over the handling of delayed multipart in this PR?

@gregw
Copy link
Contributor Author

gregw commented Aug 23, 2024

@sbordet can you do the h2 handling for this
@lorban can you do the h3 handling for this

…tty-12.1.x/delayedDispatch

# Conflicts:
#	jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
#	jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/AbstractTest.java
#	jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/ServletTest.java
#	jetty-ee11/jetty-ee11-servlet/src/test/java/org/eclipse/jetty/ee11/servlet/ServletTest.java
#	jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ServletTest.java
@gregw
Copy link
Contributor Author

gregw commented Sep 15, 2024

@sbordet can you do the h2 handling for this
@lorban can you do the h3 handling for this

@gregw
Copy link
Contributor Author

gregw commented Nov 12, 2024

I found several bugs in XmlConfiguration that prevented it being used with a Builder pattern. This PR now fixes them so we can build a MultiPartConfig in XML. Adding @lachlan-roberts to reviewers so he can check that.

Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

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

I like this approach much better.

Mostly nits, but few more important ones.

Documentation and DistributionTests are missing, but I can add them.

@gregw gregw requested a review from sbordet November 13, 2024 11:07
@gregw gregw requested a review from sbordet November 13, 2024 20:19
sbordet and others added 5 commits November 13, 2024 21:30
The javadoc of the Servlet API says:
> If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream or getReader can interfere with the execution of this method.

So there is no requirement to detect or ignore somebody reading before calling a parameter method
@sbordet
Copy link
Contributor

sbordet commented Nov 14, 2024

@gregw don't merge yet, I'm writing the documentation.

@gregw
Copy link
Contributor Author

gregw commented Nov 14, 2024

@lorban @lachlan-roberts please re-review

# jetty.eager.multipart.location=/tmp

## The maximum number of parts that can be parsed from the MultiPart content, or -1 for unlimited.
# jetty.eager.multipart.maxParts=100
Copy link
Contributor

Choose a reason for hiding this comment

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

Still a bit weird that you have -1 for default above and -1 for unlimited for these ones.

I do prefer -1 being unlimited not default, you said you can just set MAX_VALUE for unlimited, but that is a bit more annoying because you don't know from here if its an int or a long.

@gregw gregw merged commit ceca92c into jetty-12.1.x Nov 17, 2024
10 checks passed
@gregw gregw deleted the experiment/jetty-12.1.x/delayedDispatch branch November 17, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants