Closed hohwille closed 8 years ago
Which preconfigured values do you mean? I am not really getting the problem here. Actually, due to your pull request now correlationIdHttpHeaderName
can remain null
if there is no value provided by the filterConfig.
@maybeec I wrote a test which verifies that correlationIdHttpHeaderName
does not become null
under the following circumstances:
DiagnosticContextFilter
called (init
not yet called)FilterConfig.getInitParameter
returns null
FilterConfig.getInitParameter
returns non-default value.Have a look at the test class in my fork
Do you agree with this solution?
I am fine with this. The only thing I would state as a remark regarding your test implementation is, that you should not catch any exceptions. Just state throws Exception on each test if necessary. This will make analysis easier if the test fails.
https://github.com/oasp/oasp4j/blob/develop/modules/logging/src/main/java/io/oasp/module/logging/common/impl/DiagnosticContextFilter.java#L129
This code was developed with only Servlet API in mind. With modern spring and spring-boot technology you can easily provide filters as beans from code. Then you may want to call setters in that @Bean method to configure the filter. However, due to the Servlet API lifecycle and spec, spring has to call the init method. As there is no config then our current code overrides the already preconfigured values with defaults. This is IMHO a bug.