Circular dependency between AdministrationService and EventListeners

I’m running into an issue with a module that registers a spring aop aspect and it fails to start with a BeanCurrentlyInCreationException, this is because AdministrationServiceImpl has an eventListeners property which is wired into it via spring and at the same time it is registered as one of the listeners. I’m not sure why it’s showing up now but it’s clearly a circular dependency, it’s bad practice and we should fix it.

My proposed solution is to not wire the event listeners property, we should just look it up from the application context using Context.getRegisteredBeans(EventListeners.class) where it is used in AdminService, of course we can cache it in the AdminService instance so that it’s only looked up once.

Other ideas are welcome.

Did you confirm that such a change fixes the problem?

Yes, that does fix it

In that case, i have no objection to your proposal. Remember to leave a comment in the code explaining why we have had to do it that way. :slight_smile:

I resolved the issue in an alternative way from the module, I still think though that we should fix it so I will create a ticket for someone else to take on.