Fix Jetty CORS simple request TCK handling - #1060
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR fixes Jetty-specific handling around unread form/multipart request bodies so Jetty can reliably commit responses (including CORS), and re-enables the Jetty TCK case that was previously excluded.
Changes:
- Re-enable
CorsSimpleRequestTestfor the Jetty HTTP server TCK suite. - Add a
prepareForResponse()hook to allow servlet engines to consume unread request bodies before committing responses. - Split Jetty-specific unread-form-body consumption into
JettyServletHttpRequestand aJettyServletHttpHandlerthat replaces the default handler.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test-suite-http-server-tck-jetty/src/test/java/io/micronaut/http/server/tck/jetty/tests/JettyHttpServerTestSuite.java | Re-enables the Jetty CORS simple request TCK test by removing an exclusion. |
| servlet-engine/src/main/java/io/micronaut/servlet/engine/DefaultServletHttpRequest.java | Makes request body lazy + adds response-prep hook and overridable container-specific form-body preparation. |
| servlet-engine/src/main/java/io/micronaut/servlet/engine/DefaultServletHttpHandler.java | Exposes protected accessors needed by a Jetty-specific handler replacement. |
| servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpRequest.java | Introduces prepareForResponse() extension point for servlet-based requests. |
| servlet-core/src/main/java/io/micronaut/servlet/http/ServletHttpHandler.java | Invokes prepareForResponse() prior to response transfer/commit. |
| http-server-jetty/src/main/java/io/micronaut/servlet/jetty/JettyServletHttpRequest.java | Implements Jetty-native unread-body consumption for form/multipart before response commit. |
| http-server-jetty/src/main/java/io/micronaut/servlet/jetty/JettyServletHttpHandler.java | Replaces the default handler to create the Jetty-specific request implementation. |
|
@copilot apply changes based on the comments in this thread |
Applied all four changes from the review thread in commit b6f91e8:
Also added Javadoc to Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
…azy bodyAccessed, restore async path, use delegate() Agent-Logs-Url: https://github.com/micronaut-projects/micronaut-servlet/sessions/9c56aab2-dd08-417b-9188-0fe3875fbfa4 Co-authored-by: graemerocher <66626+graemerocher@users.noreply.github.com>
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
Co-Authored-By: Codex with GPT-5 <codex@openai.com>
80c521d to
f571be5
Compare
|
| all { | ||
| resources.autodetect() | ||
| buildArgs.add("-H:+SharedArenaSupport") | ||
| if (JavaVersion.current().majorVersion.toInteger() >= 25) { |
| this.messageBodyHandlerRegistry = messageBodyHandlerRegistry; | ||
| this.ioExecutor = ioExecutor; | ||
| this.sslSessionProvider = sslSessionProvider; | ||
| long contentLengthLong = delegate.getContentLengthLong(); |
There was a problem hiding this comment.
why this change? if it's just to close the source stream, this seems like the wrong layer to make the change.
There was a problem hiding this comment.
I guess it was to make the bytebody initialization lazy?



Summary
CorsSimpleRequestTestin the Jetty TCK suiteVerification
./gradlew :micronaut-http-server-jetty:compileJava./gradlew :test-suite-http-server-tck-jetty:test --tests '*FormUrlEncodedBodyInRequestFilterTest.bodyParsingInFilter' --tests '*CorsSimpleRequestTest.corsSimpleRequestAllowedForLocalhostAndOriginLocalhost'Resolves #929