Description
There are various places in the source code (in particular, Pattern and JSON Template layouts) where plugins are extensively used. There plugins are discovered via PluginManager but instantiated using some custom logic afterwards. This approach has serious caveats:
- Code duplication
- ConstraintValidator checks (e.g., RequiredClass) are ignored
- Injection is ignored
- All other PluginBuilder checks and functionalities are discarded and this breaks the plugin contract
All plugins should rather be instantiated using PluginBuilder.
This flaw also hints us that the developer-facing API of plugins is severely convoluted to the point of maintainers cannot simply discover-and-load a plugin without making a mistake. PluginUtil was an attempt to improve this situation, though it first needs to be used by the rest of the code base and it also suffers from the above custom instantiation logic shortcoming.
Attachments
Issue Links
- is part of
-
LOG4J2-2803 Create standardized scopes and dependency injection API
- Resolved