Alright, thanks for the context.
Overall IMO the real bug is within the framework as mixing CDI and statics seems high risk - especially where those statics contain references to beans so I will be looking to contribute a fix there.
Theoretically, you could have an observer for CDI lifecycle event and once notified about anything meaning the container is about to shut down(such as @BeforeDestroyed(ApplicationScoped.class) observer or within CDI extension you could have BeforeShutdown observer ), you could clear the references/beans. Especially if those beans are resolved via Instance<?>, then it is users responsibility to clean them up. |