NettyHeadersAdapter.add() accepts @Nullable
header value, but then calls io.netty.handler.codec.http.HttpHeaders
method add
, the implementation of which (DefaultHttpHeaders
-> DefaultHeaders
) throws a NullPointerException if the value is null
I would expect a method accepting a @Nullable
value not to throw NPE
Perhaps an if (value != null)
check should be implemented in NettyHeadersAdapter.add()
before calling HttpHeaders.add()
?
Context:
I have a WebFilter
that adds the x-request-id
header from the request to the response
This issue is not easy to predict in testing, because with SpringBootTest.WebEnvironment.MOCK
, ServerWebExcahnge.request.headers
returns a MultiValueMapAdapter
instead of NettyHeadersAdapter
, which is indeed null-safe.
So I only got NPE when the app was deployed to the server, not in tests