AddHttpHeaderToLogContextFilter: Filter immediately for getField presence#184
Conversation
…ence * Previously the present of a field name was checked after fetchin the header value and then dropped. This can be done once and during initialization.
KarstenSchnitter
left a comment
There was a problem hiding this comment.
Thanks for providing this change. The code has probably little affect. The point of an HttpHeader is to provide a mapping of a header to a field, when isPropagated is set to true. The null check was put in place to avoid NPEs.
I am wondering, whether the filter should issue an INFO level log, when it encounters a "propagated" header without a field. I would see this as a violation of the HttpHeader contract.
|
I phrase it the other way round. There is the invariant
I think no. When field is null, the retrieved header value is ignored. So the early filtering reduces work - like for |
|
I don't known how many breaking changes you 'dare' with the next major release. The HttpHeader interface could be changed to a sealed one, that allows the current Enum and a new HttpHeaderRecord record class. The latter can enforce the contract and consumers can still create own Headers. Just some thoughts. |
|
For the next major release, I am thinking of moving the HttpHeader interface from the core module to the servlet module. This would already be a breaking change. Implementing your suggestion would be an additional and possible option. |
AddHttpHeaderToLogContextFilter: Filter immediately for getField presence
This can be done once and during initialization.