Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Lazy initialize deprecation logger in parser #26210
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.