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

An omnibus PR for changes needed to support webfunctions #10563

Merged
merged 17 commits into from
Sep 26, 2023

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Sep 21, 2023

Web functions are currently supported with servlets. These changes add/move utility classes to core to better support direct usage of core APIs:

  • Moved Encoded HttpWriter implementations to jetty-io in core.
  • Added a ChunkAccumulator

Web functions are currently supported with servlets. These changes add/move utility classes to core to better support direct usage of core APIs
@gregw
Copy link
Contributor Author

gregw commented Sep 22, 2023

jetty-core/jetty-io/src/main/java/module-info.java Outdated Show resolved Hide resolved
*/
public boolean add(Chunk chunk)
{
if (chunk.hasRemaining())
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this check, I would add regardless.
The problem is that the caller has to check the return value (because otherwise nobody will release the chunk).
This method is currently used only within a test for hasRemaining() and does not check the return value.

Copy link
Contributor Author

@gregw gregw Sep 24, 2023

Choose a reason for hiding this comment

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

It was really to avoid adding error chunks. I'll test that explicitly instead, although that will stop any optimizations of 1 chunk lists if empty chunks are added to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually changed to do the retain in the method now, so this makes more sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still an awkward API to use in general, see also comment below.

Comment on lines 34 to 35
protected final OutputStream _out;
protected final ByteArrayOutputStream2 _bytes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Make these private. They either have getters or only used internally by inner classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I make them private I just have to add protected getters. I don't see the point?

@gregw
Copy link
Contributor Author

gregw commented Sep 24, 2023

@sbordet I've made ResponseWriter explicitly depend on our OutputStreamWriter abstraction, but using the name AbstractOutputStreamWriter was both long and a bit meaningless. I have renamed to WriteThroughWriter to capture what it does. I guess technically that should be WriteThroughOutputStreamWriter but that's a mouthful.

Note I also looked at removing even the temporary buffering in the iso and utf8 versions.... as they could easily just call write(int) on the OutputStream for each converted byte. However, there is locking and state checks and all sorts of stuff going on in HttpOutput#write(int) that I think would be best done once rather than for every byte. Thus I think the temporary buffering is worth it. However, I might try to avoid the char buffer....

@gregw gregw marked this pull request as ready for review September 26, 2023 01:23
@gregw
Copy link
Contributor Author

gregw commented Sep 26, 2023

I have a green local build on GoogleCloudPlatform/functions-framework-java#235, so would be good to have this PR in the next release so I can progress next month.

@gregw gregw requested a review from sbordet September 26, 2023 02:10
@gregw gregw requested a review from sbordet September 26, 2023 20:43
@gregw gregw merged commit 1a207db into jetty-12.0.x Sep 26, 2023
@gregw gregw deleted the experiment/jetty-12/updatesForWebFunctions branch September 26, 2023 23:29
gregw added a commit that referenced this pull request Oct 2, 2023
Do not persist a defaulted charset used in the request.
gregw added a commit that referenced this pull request Oct 3, 2023
Do not persist a defaulted charset used in the request.
Throw UnsupportedEncodingException from getReader
gregw added a commit that referenced this pull request Oct 3, 2023
Do not persist a defaulted charset used in the request.
Throw `UnsupportedEncodingException` from `getReader`
gregw added a commit that referenced this pull request Oct 3, 2023
Do not persist a defaulted charset used in the request.
Throw UnsupportedEncodingException from getReader
Improve performance with asciiEqualsIgnoreCase
HttpMethod is case-insensitive
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