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
NettyHeadersAdapter.add() accepts
@Nullableheader value, but then callsio.netty.handler.codec.http.HttpHeadersmethodadd, the implementation of which (DefaultHttpHeaders->DefaultHeaders) throws a NullPointerException if the value is nullI would expect a method accepting a
@Nullablevalue not to throw NPEPerhaps an
if (value != null)check should be implemented inNettyHeadersAdapter.add()before callingHttpHeaders.add()?Context:
I have a
WebFilterthat adds thex-request-idheader from the request to the responseThis issue is not easy to predict in testing, because with
SpringBootTest.WebEnvironment.MOCK,ServerWebExcahnge.request.headersreturns aMultiValueMapAdapterinstead ofNettyHeadersAdapter, which is indeed null-safe.So I only got NPE when the app was deployed to the server, not in tests