You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@steinsag What are you trying to achieve by setting an HTTP header to null?
HTTP headers are strings, they can be empty, but null is not a valid value.
If you want to set an empty String, use add(name, "").
Otherwise you should filter out invalid values, like you filter out non-numbers for HTTP headers that only take numerical values such as Content-Length.
This change was done in 12 to make the behavior of HttpFields consistent: in Jetty 11, if you used add(HttpHeader, String) instead of add(String, String), you would get IllegalArgumentException for null values.
So null was treated differently depending on the signature of the method.
In Jetty 12 we made the handling of null values consistent.
Our use-case are including some optional trace IDs, which we might have received from an upstream consumer of our service. In the past, we could include them without filtering null values. Jetty simply ignored such null values.
As Jetty is now rejecting null values, it breaks several of our services and we would need to add logic to only set those trace headers if they have a valid value.
String someOptionalTraceId = ??? <--- could be null, but also a valid string
...
Map<String, String> someHeaders = new HashMap<>();
someHeaders.put("X-TRACE-ID", someOptionalTraceId);
WebClient build = WebClient.builder().build();
build.get().uri("http://example.com/").headers(
httpHeaders -> someHeaders.forEach(httpHeaders::add)
);
This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.
Spring Web 6.1 uses Jetty 12. Jetty 12 changed the implementation of
org.springframework.http.client.reactive.JettyClientHttpRequest#applyHeaders
from (Jetty 11)
to
This now breaks Spring Web 6.1.
A similar issue was reported in: #10508
I initially reported this issue to Spring project, but they say this is a regression in Jetty: spring-projects/spring-framework#31714
The text was updated successfully, but these errors were encountered: