Skip to content

[refactor] Migrate HTTP usage to Apache HttpClient 5; drop Milton + outdated HC4 deps#6473

Closed
joewiz wants to merge 7 commits into
eXist-db:developfrom
joewiz:feature/hc5-finish
Closed

[refactor] Migrate HTTP usage to Apache HttpClient 5; drop Milton + outdated HC4 deps#6473
joewiz wants to merge 7 commits into
eXist-db:developfrom
joewiz:feature/hc5-finish

Conversation

@joewiz

@joewiz joewiz commented Jun 13, 2026

Copy link
Copy Markdown
Member

[This PR was co-authored with Claude Code. -Joe]

Continues and supersedes #6393 by @duncdrum (his commits are preserved here, rebased onto current develop). Picks up where that draft left off now that Saxon 12, Jackrabbit WebDAV (#6364), and Jetty 12 (#6392) have all landed.

Summary

Migrates eXist-owned HTTP usage from Apache HttpClient 4.x to HttpClient 5.x across the code base, removes the dead Milton WebDAV test infrastructure that #6364 left behind, and drops the now-unused HC4 dependencies. Goal: consistent HTTP interactions throughout, and fewer outdated deps.

What changed

@duncdrum's work (rebased, authorship preserved): integration tests + eXist-owned HTTP code migrated HC4 → HC5 (5.6.1); removed the 8 milton-client WebDAV tests + com.ettrema stubs, added JDK-HttpClient round-trip tests (WebDavRoundTripTest, WebDavHttpTest); standalone web.xml uses the Jackrabbit servlet.

Finishing work (this continuation):

  • Migrated three tests develop added after the original branch and still on HC4: URLRewriteViewPipelineTest, the vector tests in JmxRemoteTest, and RestBinariesTest (restored an HC5 postXquery returning ClassicHttpResponse for the response:stream-binary-resource tests; postXqueryBody delegates to it).
  • Dropped HC4 httpclient / httpmime / fluent-hc from the parent BOM + the unused apache.httpcomponents.version property.
  • Removed the stale Milton logger from exist-distribution log4j2.xml; debuggee inherits the BOM-managed HC5 version; bumped http-client-java 1.4.2 → 1.5.2 (supersedes dependabot Bump org.expath.http.client:http-client-java from 1.4.2 to 1.5.2 #5346).

One HC4 dependency remains, and why

extensions/expath keeps HC4 httpcore — solely for EXistTreeBuilder, which iterates org.apache.http.Header exposed by the EXPath http-client-java library. That library is still HC4 at its latest release: http-client-java 1.5.2's HeaderSet implements Iterable<org.apache.http.Header>, identical to 1.4.2. So full HC4 removal isn't possible until http-client-java itself migrates to HC5; httpcore (HC4) is scoped to expath and documented in its pom.

Test plan

  • exist-core HTTP integration suite — 46 tests green (REST, urlrewrite, JMX, request, security, session, auth)
  • restxq integration tests — 20 green
  • webdav round-trip tests — 4 green (+ webdav module ITs)
  • Full reactor compiles (exist-xqts needs GitHub Packages auth — environment, not code)
  • Codacy/PMD clean on changed Java

duncdrum and others added 7 commits June 13, 2026 12:54
Add HC5 BOM (httpclient5/httpclient5-fluent 5.6.1, httpcore5 5.4) alongside
HC4 for hybrid coexistence. Migrate exist-core and extension HTTP tests to
org.apache.hc.*; keep extensions/webdav on HC4 for milton-client JUnit tests.

HC5 fluent Executor auth does not reliably attach Basic credentials to
/exist/... URLs, so AbstractHttpTest adds a preemptive Authorization
interceptor (same pattern in restxq and file module tests).

Co-authored-by: Cursor <cursoragent@cursor.com>
Publish exist-core test-jar so extension ITs share AbstractHttpTest.
Simplify auth to a preemptive Authorization interceptor only; add
AuthenticatedHttpClientTest regression guard. Close HTTP responses in
restxq helpers; dedupe auth in restxq/file. LoginModuleIT: disable
retries and close responses. Document expath HC4/HC5 hybrid. Close
MoveResourceTest connection pool after class.
Removes HC4/milton-client test harness from exist-webdav (Gate A).
Litmus bats cover RFC compliance; WebDavRoundTripTest keeps
eXist-specific XML serialization checks (DOCTYPE, xml-decl, CDATA).
These three tests landed on develop after the original HC5 branch (eXist-db#6393) and were
still on HttpClient 4, so they broke once HC4 left the exist-core test classpath:

- URLRewriteViewPipelineTest: fluent Request.Get/Put/Delete -> get/put/delete,
  HttpResponse -> ClassicHttpResponse, getStatusLine().getStatusCode() -> getCode().
- JmxRemoteTest: the vector-category tests used Request.Get (HC4) -> Request.get (HC5).
- RestBinariesTest: restore an HC5 postXquery() returning ClassicHttpResponse for the
  response:stream-binary-resource tests (which read headers/entity); postXqueryBody()
  now delegates to it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Now that all eXist-owned HTTP code is on HttpClient 5, remove the outdated HC4
dependencies that nothing declares anymore:

- exist-parent BOM: drop httpclient, httpmime and fluent-hc (HC4) and the now-unused
  apache.httpcomponents.version property. Keep httpcore (HC4) only, for expath.
- exist-distribution log4j2.xml: drop the stale Milton (com.bradmcevoy) logger.
- debuggee: inherit the BOM-managed httpclient5-fluent version instead of pinning 5.6.1.
- expath: bump http-client-java 1.4.2 -> 1.5.2 (supersedes dependabot eXist-db#5346) and correct
  the pom note. EXistTreeBuilder still needs HC4 httpcore: the EXPath http-client-java
  library is HC4 even at 1.5.2 (its HeaderSet implements Iterable<org.apache.http.Header>),
  so httpcore cannot be dropped until that library migrates to HC5.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joewiz joewiz requested a review from a team as a code owner June 13, 2026 17:38

@dizzzz dizzzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM - I was wondering if we could not ditch apache http client and simplify stuff by using the native Java9+ HttpClient (with optionally the Methanol library where needed for specials)

@dizzzz dizzzz requested review from a team, duncdrum, line-o and reinhapa June 13, 2026 18:13
@dizzzz

dizzzz commented Jun 13, 2026

Copy link
Copy Markdown
Member

Are there still sufficient webdav tests? @joewiz I recall you introduced a 3rd party test framework right?

@duncdrum

Copy link
Copy Markdown
Contributor

Thank you @joewiz looks good to me. There might be room for more optimizations but this seems to capture the bulk of it and is a big step in the right directions.

@joewiz

joewiz commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

[This response was co-authored with Claude Code. -Joe]

Superseded by #6482, which takes the EXPath HTTP client native on the JDK java.net.http.HttpClient + Methanol and removes Apache HttpClient entirely — reaching the same "no Apache HttpClient" end state without the intermediate HC5 step. The test-infrastructure migration and the Milton WebDAV cleanup from this PR are carried into #6482. Closing in favor of that PR.

@joewiz joewiz closed this Jun 15, 2026
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.

3 participants