With Togglz 2.5.0.Final and Spring Boot, if we setup the actuator endpoints in a dedicated context (by using the property management.server.port
to specify a separate port), Spring will emit two ContextRefreshedEvent
events, one for the main context and another for the management context.
This results in the following warning by Tooglz in the log:
2018-06-29 13:52:41.414 WARN 29069 --- [ main] licationContextBinderApplicationListener : ApplicationContext already bound to current context class loader, releasing it first
I have placed a breakpoint in TogglzApplicationContextBinderApplicationListener.onApplicationEvent
and run several tests, and it appears that the management event is always received first.
This means that after the application starts up, the ContextClassLoaderApplicationContextHolder
ends up containing the correct (main) application context.
However, I cannot be certain that the order of these events is always the observed one, and I don't think Spring Boot makes no such guarantees, which means that even if the order is correct now, it may not be in some future version.
I think that Togglz should not rely on the order of these events, and I propose that ContextRefreshedEvent
events originating from the management context should instead be ignored.
If you agree with this idea, I can work on a PR to implement it.
Thanks and best regards
bug