Skip to content

Make CELFormatterCommandParser function without a thread-singleton#44278

Closed
ravenblackx wants to merge 1 commit intoenvoyproxy:mainfrom
ravenblackx:cel_formatter_dep
Closed

Make CELFormatterCommandParser function without a thread-singleton#44278
ravenblackx wants to merge 1 commit intoenvoyproxy:mainfrom
ravenblackx:cel_formatter_dep

Conversation

@ravenblackx
Copy link
Copy Markdown
Contributor

Commit Message: Make CELFormatterCommandParser function without a thread-singleton
Additional Description: Previously, initializing a CELFormatterCommandParser (e.g. from yaml instantiating a SubstitutionFormatString) uses the ServerConfigurationFactoryContext singleton, which only works after server initialization. This means that in tests an ASSERT fails: ThreadLocalInjectableSingleton used prior to initialization. In unit tests this can be mitigated by initializing a ScopedThreadLocalServerContextSetter, but this issue also occurs in the config validator used by CI. Rather than making that test also work around this issue, we can use the GenericFactoryContext that's available in this code path to initialize a reference with the required context via proper dependency injection.

There's a second initialization path that doesn't have a FactoryContext available, so that one still uses the singleton, to initialize the injected reference - the path that checks configs doesn't use that path, so this solves the immediate problem.
Risk Level: Negative, it fixes an issue and changes no behavior except making for fewer touches of a singleton-instance.
Testing: Updated tests to use the modified constructor.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Raven Black <ravenblack@dropbox.com>
@ravenblackx
Copy link
Copy Markdown
Contributor Author

Ugh, never mind, the BuiltInCommandParserFactory initialization occurs before the singleton is initialized, making it a much bigger deal to refactor.

@ravenblackx ravenblackx closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants