Skip to content

Conversation

@lachlan-roberts
Copy link

This is based on the work from #235.

Port the invoker to upgrade to Eclipse Jetty-12 version 12. Specifically using the new core APIs of Eclipse Jetty-12 that allow the overhead of a Servlet container to be avoided.

BREAKING CHANGE: use Java 17 or above, as required by Eclipse Jetty-12.

Replaces

Port the invoker to upgrade to Eclipse Jetty-12 version 12.  Specifically using the new core APIs of Eclipse Jetty-12 that allow the overhead of a Servlet container to be avoided.

BREAKING CHANGE: use Java 17 or above, as required by Eclipse Jetty-12.

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
Port the invoker to upgrade to Eclipse Jetty-12 version 12.  Specifically using the new core APIs of Eclipse Jetty-12 that allow the overhead of a Servlet container to be avoided.

BREAKING CHANGE: use Java 17 or above, as required by Eclipse Jetty-12.

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
@lachlan-roberts lachlan-roberts changed the title use Jetty-12.1 core without servlets chore(implementation): use Jetty-12 core without servlets Sep 30, 2025
@lachlan-roberts lachlan-roberts changed the title chore(implementation): use Jetty-12 core without servlets chore(implementation): use Jetty-12.1 core without servlets Sep 30, 2025
@ludoch
Copy link
Collaborator

ludoch commented Oct 3, 2025

Thanks!
We need to remove jdk11 constraints in builds. I guess only a Googler can understand and change the kokoro files to jdk17

Also all references with maven.compiler.source>11</maven.compiler.source> need to change to 17

@ludoch ludoch requested a review from akerekes October 3, 2025 18:02
@ludoch
Copy link
Collaborator

ludoch commented Oct 3, 2025

@akerekes please help on google internal kokoro workflows.
The entire new code now has to only work with java17,21 and 25, so drop 11 and add new configs.

@ludoch ludoch self-requested a review October 3, 2025 18:04
@akerekes
Copy link
Contributor

akerekes commented Oct 3, 2025

Hi @lachlan-roberts , thank you for the PR! I'll work on the Google internal side. One note on the timeline is that Cloud Function deprecates java11 at the end of the month: https://cloud.google.com/functions/docs/runtime-support#java so my preference is to have this PR ready to merge, but wait until the end of the month with the merge, then do it in early November and release a new version of the FF-java library.

Copy link
Contributor

@akerekes akerekes left a comment

Choose a reason for hiding this comment

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

Thank you @lachlan-roberts for the PR! I did the first round of review.

Please rebase the PR to HEAD one more time, I'm not planning to merge any other PRs until this one is done to avoid further rebasing and merge conflicts.

Port the invoker to upgrade to Eclipse Jetty-12 version 12.  Specifically using the new core APIs of Eclipse Jetty-12 that allow the overhead of a Servlet container to be avoided.

BREAKING CHANGE: use Java 17 or above, as required by Eclipse Jetty-12.

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
} finally {
executionIdUtil.removeExecutionId();
}
return true;
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here or at the top of the method explaining the return value? It seems confusing to me at face value

Copy link
Author

Choose a reason for hiding this comment

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

This is specified in the javadoc of handle

Returns:
True if and only if the request will be handled, a response generated and the callback eventually called. This may occur within the scope of the call to this method, or asynchronously some time later. If false is returned, then this method must not generate a response, nor complete the callback.

In this case we are always handling the request so we should always return true.

FunctionExecutor<CloudEventT> executor = (FunctionExecutor<CloudEventT>) functionExecutor;
byte[] body = req.getInputStream().readAllBytes();

byte[] body = Content.Source.asByteArrayAsync(req, -1).get();
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this array manipulation in a comment? why the '-1'?

Copy link
Author

Choose a reason for hiding this comment

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

This asByteArrayAsync method is now deprecated without replacement, I have opened jetty/jetty.project#13939 for an replacement method as Content.Source.asInputStream(req).readAllBytes() could be much less efficient.

But this is simply reading the entire content of the request into a byte[]. The second argument was the length of the content with -1 meaning read until EOF.

new TimerTask() {
@Override
public void run() {
// TODO: there is a race between the handler writing response and timeout firing.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the action item to this TODO? what needs to be done to address this race condition?

Copy link
Author

Choose a reason for hiding this comment

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

The race condition is intrinsic to this approach, and was also present using the original TimeoutFilter. And there were also various other problems with the original TimeoutFilter.

I have pushed another commit to improve this.

  • Before the timeout was per call to doFilter, it was not measuring the total time for the handling of the request/response to complete.
  • It used to create a new Timer for every call to doFilter() (possibly multiple times per request), now it reuses the Scheduler of the server and only once per request.

@akerekes
Copy link
Contributor

@lachlan-roberts Thank you for the follow-up. Can you reformat the code to make the linter check pass?

The PR looks good to me, I'm waiting on @maemayve 's comments to be resolved and happy to approve it then.

Port the invoker to upgrade to Eclipse Jetty-12 version 12.  Specifically using the new core APIs of Eclipse Jetty-12 that allow the overhead of a Servlet container to be avoided.

BREAKING CHANGE: use Java 17 or above, as required by Eclipse Jetty-12.

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
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.

4 participants