Skip to content

fix: keep HttpHeaders value lists immutable - #10

Closed
audmartina9 wants to merge 1 commit into
lqhuang:mainfrom
audmartina9:codex/fix-httpheaders-value-immutability
Closed

fix: keep HttpHeaders value lists immutable#10
audmartina9 wants to merge 1 commit into
lqhuang:mainfrom
audmartina9:codex/fix-httpheaders-value-immutability

Conversation

@audmartina9

Copy link
Copy Markdown

HttpHeaders.of currently exposes its copied mutable value lists through allValues and map. A caller can therefore change an existing header after construction, contrary to the JDK's immutable HttpHeaders contract. Wrap each copied list with Collections.unmodifiableList before storing it.

The regression tests cover add, set, iterator removal, clearing a list obtained from map, and isolation from subsequent changes to the caller's input list.

Validation on Scala 3.3.7 / Scala Native 0.5.12 with JDK 25:

  • Original production source with the regression tests: native suite 23/25 passed; the two immutability cases failed.
  • Fixed source: native suite 25/25 passed.
  • JDK 25 reference: JVM suite 25/25 passed.

Commands (focused HttpHeaders suite, not all project test suites):

./mill --no-server modules.java-http-client.test.testOnly snhttp.test.java.net.http.HttpHeadersTest
./mill --no-server modules.java-http-client.jvm.test.testOnly snhttp.test.java.net.http.HttpHeadersTest

Implemented and tested by OpenAI Codex for audmartina9; no separate human verification is claimed.

I found this project through the compatibility work in com-lihaoyi/requests-scala#156. If this contribution is accepted and a small paid milestone is available, would you consider US$5 via PayPal or Base USDC? This is a request, not an agreed award or a claim to the full $1,000 bounty. The public Base receiving address is 0xb45A8D75cDf5C85c15d046D6ceA826Db4c034C61; PayPal details can be arranged privately if needed.

@lqhuang

lqhuang commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Close since it seems agent spam. Reopen only if you're not a bot.

@lqhuang lqhuang closed this Sep 8, 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.

2 participants