Skip to content
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

Avoid circular reference warning with DiscoveryServiceHelper #2650

Closed
1 of 3 tasks
stefan-egli opened this issue Jul 21, 2021 · 3 comments
Closed
1 of 3 tasks

Avoid circular reference warning with DiscoveryServiceHelper #2650

stefan-egli opened this issue Jul 21, 2021 · 3 comments
Milestone

Comments

@stefan-egli
Copy link
Contributor

Required Information

  • AEM Version, including Service Packs, Cumulative Fix Packs, etc: _______
  • ACS AEM Commons Version: 5.0.4
  • Reproducible on Latest? yes/no

Expected Behavior

Startup of AEM with acs-aem-commons deployed should not issue a log.error about a circular reference with DiscoveryServiceHelper (and OakDiscoveryService)

Actual Behavior

Startup of AEM with acs-aem-commons (seen with 5.0.4 but presumably also happens with latest as that code hasn't changed) issues the following log.error:

ERROR [FelixLogListener] ROOT bundle org.apache.felix.scr:2.1.26 (44) Circular reference detected trying to get service [org.apache.sling.discovery.DiscoveryService, org.apache.sling.discovery.oak.OakDiscoveryService]
 stack of references: ServiceReference: [org.apache.sling.discovery.DiscoveryService, org.apache.sling.discovery.oak.OakDiscoveryService]
ServiceReference: [org.apache.sling.discovery.TopologyEventListener]
 (java.lang.Exception: stack trace)
java.lang.Exception: stack trace
	at org.apache.felix.scr.impl.ComponentRegistry.enterCreate(ComponentRegistry.java:493) [org.apache.felix.scr:2.1.26]
	at org.apache.felix.scr.impl.BundleComponentActivator.enterCreate(BundleComponentActivator.java:717) [org.apache.felix.scr:2.1.26]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:899) [org.apache.felix.scr:2.1.26]
	at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:348)
<cut>
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:984) [org.apache.felix.scr:2.1.26]

and

WARN [FelixLogListener] com.adobe.acs.commons.util.impl.DiscoveryServiceHelper bundle com.adobe.acs.acs-aem-commons-bundle:5.0.4 (574)[com.adobe.acs.commons.util.impl.DiscoveryServiceHelper(3208)] : Could not get service from ref [org.apache.sling.discovery.DiscoveryService, org.apache.sling.discovery.oak.OakDiscoveryService]

Steps to Reproduce

Note that this was not seen with a Vanilla AEM but with AEM as a Cloud Service - hence the exact timing that reproduces this might also be influenced by other packages/bundles deployed.

Having said that, the error is a result of the fact that OakDiscoveryService being a DiscoveryService as well as it itself manages TopologyEventListeners - and DiscoveryServiceHelper being both a TopologyEventListener as well as having a reference to DiscoveryService

Links

Links to related assets, e.g. content packages containing test components

@stefan-egli
Copy link
Contributor Author

I'd say it's complicated.

Technically the log.error that shows up is only somewhat overly loud - as later on the situation clears as it turns out it is not actually a circular reference. So from that point of view one might argue that osgi could try harder at avoiding this noise.

Then again, one could also argue from an API usage point of view - as it is indeed cleaner to use the TopologyEventHandler - as otherwise you risk race conditions between the time DiscoveryService.getTopology() is asked vs when the TopologyEventHandler is invoked. Using both concurrently is a somewhat risky task.

@kwin kwin added this to the 5.0.8 milestone Jul 21, 2021
stefan-egli added a commit to stefan-egli/acs-aem-commons that referenced this issue Jul 21, 2021
@kwin kwin closed this as completed Jul 22, 2021
@vhochstein
Copy link

According to Adobe Support this issue is responsible for extremely long runtimes of Adobes CI-CD Pipeline ?
Do you agree with Adobe Support ?

Do you have planned Release Date for Milestone 5.0.8 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants