Was wondering what others are thinking on the following: We have several components (Processors, ControllerServices etc.) both existing and coming down the pipeline which rely on class-level initializers (see example below from new SNMP PR) SecurityModels.getInstance().addSecurityModel(usm); While it’s a common pattern for certain types of use cases it doesn’t go well with the flexibility we try to promote within NiFi. Specifically the ability to have two different components that rely on such initializers being different or in different states. This is because multiple instances of the same component will be loaded by the same NAR ClassLoader and since such initializers maintain the state at the class level (singleton), they are shared across all instances of the component. So, the above example will set security model for a processor where such security model was required and it will immediately be available to another instance of the same type processor where it may not be required or supported causing hard to explain/debug errors.
There is a simple ClassLoader trick that we can discuss and implement to alleviate this (I’ve done it for another processor that is coming down the pipeline), but first I would like to know what others think, since the more I think about it the more I feel it is global concern and as such would be better addressed at the framework level. Thoughts Oleg
