Files
spring-framework/spring-web
Sam Brannen 319ecd9cf9 Test JdkClientHttpRequest header filtering in isolation
Prior to this commit, JdkClientHttpRequestFactoryTests verified the
`jdk.httpclient.allowRestrictedHeaders` support by setting the system
property in a @⁠BeforeAll method and sending a request with an "Expect"
header.

However, the JDK HttpClient reads that property only once, in a static
initializer, and JdkClientHttpRequest caches it in a static field as
well. Consequently, the test failed whenever another test class (such
as ClientHttpConnectorTests) initialized the HttpClient first in the
same JVM, making the build dependent on test class execution order.

That test also exercised the JDK's own enforcement of restricted
headers more than any logic in Spring, so it provided little value for
the cost.

Since we aim for reliable builds, in order to avoid problems with the
Spring portfolio release trains, such order-dependent failures are not
acceptable.

This commit therefore removes the end-to-end test, makes
JdkClientHttpRequest.disallowedHeaders() package-private, and tests it
directly, setting and restoring the system property around each call.
2026-10-07 16:18:59 +02:00
..