Volkan Yazici created LOG4J2-3474:
-------------------------------------

             Summary: Use PluginBuilder for instantiating plugins
                 Key: LOG4J2-3474
                 URL: https://issues.apache.org/jira/browse/LOG4J2-3474
             Project: Log4j 2
          Issue Type: Bug
          Components: Plugins
            Reporter: Volkan Yazici


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.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to