Question: Is there a proper way to ensure that HK2 shuts down with Jersey 2; if not, would this be considered a bug?
Using jersey-server 2.3.1, I've noticed that HK2 @PreDestroy
methods on managed singletons and dispose()
methods on Factory<T>
implementations are not being invoked. Doing a bit of poking around, I see that ConfigHelper
defines a lifecycle listener that invokes preDestroy()
on the service locator, but nothing more. This gets invoked from the the Jersey ServletContainer
on both shutdown()
and reload()
, but nothing further is done with the service locator in terms of shutdown.
I've looked through ServletContainer
, but there doesn't seem to be a way of accessing the HK2 service locator through any public or protected APIs.