-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore VaadinServiceInitListener from ServiceLoader if it's also discovered in some other way #531
Comments
It is no need for any annotation to happend as described in https://vaadin.com/forum/thread/17604535 |
@netbeansuser2019 It seems like I was making an invalid assumption in the forum thread. The situation described in this ticket is still something that can happen and may be confusing in similar situations. |
Rather than moving this to the Spring repo and only fixing it there, I would suggest somehow doing this on the Flow side so that service init listeners defined as CDI beans or OSGi services would also automatically be deduplicated. |
Github has frozen my long comment and I'm not able to do anything with this. It's about |
This issue is not a common issue but specific for add-ons which uses its own Instantiator implementation. I would say that this is a bug in the users code: include the same class in Another thing is : The ugly way to fix it : introduce an additional method into If you see a proper way to fix it generally please suggest. I don't see such a way. |
I was originally thinking that the logic in I was also assuming that the CDI and OSGi integrations would have their own implementations of the same method. It seems like CDI fires the event as a CDI event and there isn't any custom support for OSGi. From that point of view, it might indeed be best to only fix this is the Spring integration. |
If you have a
VaadinServiceInitListener
class defined throughMETA-INF/services/com.vaadin.flow.server.VaadinServiceInitListener
and the same class is also e.g. a Spring@Component
, then each mechanism will create one instance of that listener and it will be invoked twice which may be quite confusing.If the same class is discovered through multiple sources, then it should only be used once, and then preferably through e.g. Spring since that mechanism also allows injections and such to work as expected. Rather than just silently ignoring the other occurrence, it might be good to log a warning since the entry in
META-INF/services
is quite redundant.The text was updated successfully, but these errors were encountered: