Lazy initialize deprecation logger in parser
The deprecation logger in AbstractXContentParser is static. This is done for performance reasons, to avoid constructing a deprecation logger for every parser of which there can be many (e.g., one for every document when scripting). This is fine, but the static here is a problem because it means we touch loggers before logging is initialized (when constructing a list setting in Environment which is a precursor to initializing logging). Therefore, to maintain the previous change (not constructing a parser for every instance) but avoiding the problems with static, we have to lazy initialize here. This is not perfect, there is a volatile read behind the scenes. This could be avoided (e.g., by not using set once) but I prefer the safety that set once provides. I think this should be the approach unless it otherwise proves problematic. Relates #26210
Loading
Please register or sign in to comment