Do not send null HTTP header value in JdkClientHttpRequest

Prior to this commit, the `JdkClientHttpRequest` would add all values
from `HttpHeaders` to the native request builder. This could cause
`NullPointerException` being thrown at runtime because the `HttpClient`
does not support that.

This commit replicates a fix that was applied to the
`SimpleClientHttpRequest`, turning null values into empty "".

Fixes gh-35996
This commit is contained in:
Brian Clozel
2025-12-11 09:45:30 +01:00
parent 0eefac21c9
commit d835fe311d
2 changed files with 24 additions and 1 deletions
@@ -175,7 +175,7 @@ class JdkClientHttpRequest extends AbstractStreamingClientHttpRequest {
headers.forEach((headerName, headerValues) -> {
if (!DISALLOWED_HEADERS.contains(headerName.toLowerCase(Locale.ROOT))) {
for (String headerValue : headerValues) {
builder.header(headerName, headerValue);
builder.header(headerName, (headerValue != null) ? headerValue : "");
}
}
});