Skip to content

fix(client): respect sun.net.http.allowRestrictedHeaders after config refactor - #6118

Open
arimu1 wants to merge 1 commit into
eclipse-ee4j:4.xfrom
arimu1:fix/6085-allow-restricted-headers
Open

fix(client): respect sun.net.http.allowRestrictedHeaders after config refactor#6118
arimu1 wants to merge 1 commit into
eclipse-ee4j:4.xfrom
arimu1:fix/6085-allow-restricted-headers

Conversation

@arimu1

@arimu1 arimu1 commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Fixes a regression introduced by the HttpUrlConnector configuration refactor (2.48+): sun.net.http.allowRestrictedHeaders=true was ignored for restricted headers such as Host and Origin.

Root cause

HttpUrlConnectorConfiguration.ReadWrite#fromClient() set isRestrictedHeaderPropertySet on the intermediate this instance, then returned a copy (clientConfiguration) created earlier via copyFromClient()init() (defaults the flag to false) + setNonEmpty(this) (still empty at that point).

HttpUrlConnector stores that returned copy and later uses fromRequest() / copy(), so the system property value never reached request-time checks. Users always saw:

Attempt to send restricted header(s) while the [sun.net.http.allowRestrictedHeaders] system property not set. Header(s) will possibly be ignored

even when the property was set (e.g. OCI SDK setting Host).

Fix

Apply and log the system property on the returned clientConfiguration, matching the pre-2.48 behavior where the constructor field was assigned from the property.

Testing

  • HttpUrlConnectorRestrictedHeadersTest (3 tests):
    • fromClient records true / false on the returned config
    • value survives copy() (the path used by fromRequest)
  • Verified the two true-path tests fail on unfixed code and pass with this change
  • JDK 17 (JBR 17.0.14), mvn -pl core-client -am test -Dtest=HttpUrlConnectorRestrictedHeadersTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Fixes #6085

fromClient() set isRestrictedHeaderPropertySet on the intermediate
ReadWrite instance instead of the returned clientConfiguration copy.
After the 2.48 configuration refactor, the stored client config always
kept the init() default of false, so restricted headers (Host, Origin,
…) were treated as disallowed even when sun.net.http.allowRestrictedHeaders
was true.

Apply the system property to the returned configuration so it propagates
through fromRequest()/copy() as before the refactor.

Fixes eclipse-ee4j#6085

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.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.

Regression: sun.net.http.allowRestrictedHeaders is not always respected for restricted headers

1 participant