Skip to content

Remove pre-Servlet 3.1 compatibility code#2955

Open
gnodet wants to merge 7 commits intomainfrom
cleanup/remove-pre-servlet31-compat
Open

Remove pre-Servlet 3.1 compatibility code#2955
gnodet wants to merge 7 commits intomainfrom
cleanup/remove-pre-servlet31-compat

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 12, 2026

Summary

  • Removes dead pre-Servlet 3.1 backward-compatibility code — CXF now requires Jakarta Servlet 6.x, so the runtime reflection checks for Servlet 3.0/3.1 availability are unreachable dead code
    • Removes isServlet3 field and ServletRequest.class.getMethod("isAsyncSupported") reflection check from AbstractHTTPDestination
    • Removes IS_31 static check and Servlet31Continuation subclass from Servlet3ContinuationProvider, merging the Servlet 3.1 behavior (NIO WriteListener support, isReady()) into the base Servlet3Continuation class
    • Simplifies retrieveFromContinuation() and setupContinuation() methods

Supersedes #702.

Test plan

  • rt/transports/http module compiles and tests pass
  • AsyncResponseImplTest passes (uses Servlet3ContinuationProvider)
  • CI pipeline

🤖 Generated with Claude Code

…content-type matching

CXF now requires Jakarta Servlet 6.x, so the runtime checks for Servlet 3.0/3.1
availability are dead code. This commit:

- Removes the isServlet3 field and reflection check in AbstractHTTPDestination
- Merges Servlet31Continuation into Servlet3Continuation (removing the subclass)
- Removes the IS_31 static check in Servlet3ContinuationProvider
- Simplifies retrieveFromContinuation and setupContinuation
- Fixes FormUtils.isFormPostRequest() to use startsWith instead of equals,
  so content types like "application/x-www-form-urlencoded;charset=UTF-16BE"
  are correctly recognized as form posts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
Copy link
Contributor Author

gnodet commented Mar 12, 2026

CI failure is in cxf-systests-ci-grizzly (Grizzly container integration test) — unrelated to this PR's changes. Re-triggering CI.

The merged continuation class now includes Servlet 3.1 features
(WriteListener, isReady), so rename it to Servlet31Continuation
to reflect the actual API baseline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor Author

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

Thanks for the review @reta!

Servlet31Continuation rename: Applied — renamed Servlet3Continuation to Servlet31Continuation since the merged class now includes Servlet 3.1 features (WriteListener support, isReady). Pushed as a new commit.

FormUtils change: The existing isFormPostRequest uses equals() to match the content type, but in practice the Content-Type header can include parameters like application/x-www-form-urlencoded; charset=UTF-8. The strict equality check causes form POST requests with charset parameters to be missed. Switching to startsWith() handles this correctly. I noticed this while working on the servlet compat cleanup — happy to split it out to a separate PR if you prefer.

@reta
Copy link
Member

reta commented Mar 12, 2026

FormUtils change: The existing isFormPostRequest uses equals() to match the content type, but in practice the Content-Type header can include parameters like application/x-www-form-urlencoded; charset=UTF-8.

Thanks @gnodet , to be fair seeing charset=UTF-8 with application/x-www-form-urlencoded would be somewhat strange since usage of this media type assumes the data is already urlencoded (== restricted encoding), or I am missing something? Thank you.

@gnodet
Copy link
Contributor Author

gnodet commented Mar 13, 2026

@reta Good question! The charset parameter with application/x-www-form-urlencoded is actually quite common in practice:

  1. jQuery sends application/x-www-form-urlencoded; charset=UTF-8 by default in $.ajax() — this is extremely widespread.

  2. CXF's own test suite already handles this — FormEncodingProviderTest tests with both charset=ISO-8859-1 (line 264) and charset=UTF-8 (line 283), specifically for decoding non-ASCII characters (e.g. Chinese characters). So FormEncodingProvider.readFrom() already correctly uses the charset parameter.

  3. The inconsistency: without the startsWith change, isFormPostRequest() returns false when a client sends charset=UTF-8, causing form data to not be recognized — even though the rest of CXF (FormEncodingProvider) properly handles it.

While URL-encoding restricts the bytes on the wire to ASCII, the charset parameter tells the server how to decode percent-encoded sequences back to characters (e.g. name=%E4%B8%AD%E6%96%87 decodes differently with UTF-8 vs ISO-8859-1).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet changed the title Remove pre-Servlet 3.1 compat code; fix form post content-type matching Remove pre-Servlet 3.1 compatibility code Mar 13, 2026
@reta
Copy link
Member

reta commented Mar 13, 2026

@reta Good question! The charset parameter with application/x-www-form-urlencoded is actually quite common in practice:

Thanks @gnodet , I think we could look at it, AFAIK there are so many places in CXF where we compare content types that we could improve, not just this one , thank you.

gnodet and others added 3 commits March 13, 2026 19:50
The 5-second timeout introduced in #2962 is still not sufficient for
CI environments under load. Tracing tests like
testThatNewSpanIsCreatedOnClientTimeout continue to fail with
ConditionTimeoutException at the 5-second mark. Increase all Awaitility
timeouts to 10 seconds across all tracing test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

// Await till flush happens, usually a second is enough
await().atMost(Duration.ofSeconds(5L)).until(()-> TestSpanHandler.getAllSpans().size() == 4);
await().atMost(Duration.ofSeconds(10L)).until(()-> TestSpanHandler.getAllSpans().size() == 4);
Copy link
Member

Choose a reason for hiding this comment

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

@gnodet seems like another non-related changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but they belong to a different PR. I merged the PRs into this one to work around the flaky tests in CI and make PR green. The idea would be to merge the other PRs first, then rebase this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants