adobe / adobe/aemanalyser-maven-plugin
Bundle containing ServiceLoader consumer where there are multiple providers are throwing warnings
- Dominant language
- Java
- Stars
- 30
- Forks
- 25
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 2
Description
### Expected Behaviour
We implemented a bundle containing the Require-Capability header for consuming a ServiceLoader, where there are multiple bundles providing the ServiceLoader. The analyser should not complain about this
### Actual Behaviour
Following warning is thrown:
```[WARNING] [requirements-capabilities] be.orbinson.aem:aemaacs-opentelemetry-instrumentation.core:1.0.2-SNAPSHOT: Artifact be.orbinson.aem:aemaacs-opentelemetry-instrumentation.core:1.0.2-SNAPSHOT requires [be.orbinson.aem.aemaacs-opentelemetry-instrumentation.core/1.0.2.SNAPSHOT] osgi.serviceloader; osgi.serviceloader=io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider; filter:="(osgi.serviceloader=io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider)"; cardinality:=multiple; resolution:=mandatory in start level 20 but there is more than one matching capability in this start level: [BundleInfo [symbolicName=be.orbinson.osgi.opentelemetry-exporter-logging, version=1.43.0.0001], BundleInfo [symbolicName=be.orbinson.osgi.opentelemetry-exporter-otlp, version=1.43.0.0001]] (be.orbinson.aem:aemaacs-opentelemetry-instrumentation.all:1.0.2-SNAPSHOT|be.orbinson.aem:aemaacs-opentelemetry-instrumentation.minimal:1.0.2-SNAPSHOT)```
### Reproduce Scenario (including but not limited to)
Checkout the following project and compille the code: https://github.com/orbinson/aemaacs-opentelemetry-instrumentation/tree/feature/upgrade-cardinality
To create the Require-Capability header, `bnd-maven-plugin` is used and the the `@ServiceConsumer` annotation is added to the class that requires the ServiceLoader service to be available:
https://github.com/orbinson/aemaacs-opentelemetry-instrumentation/blob/feature/upgrade-cardinality/core/src/main/java/be/orbinson/aem/opentelemetry/core/services/impl/OpenTelemetryFactoryImpl.java#L32
Apache Aries SpiFly is used to enable `ServiceLoader` in OSGi:
https://github.com/orbinson/aemaacs-opentelemetry-instrumentation/blob/feature/upgrade-cardinality/opentelemetry-okhttp-exporter/pom.xml#L215
Contributor guide
Research direction
Reproduce the warning by compiling the linked feature/upgrade-cardinality project, focusing on core/src/main/java/be/orbinson/aem/opentelemetry/core/services/impl/OpenTelemetryFactoryImpl.java and opentelemetry-okhttp-exporter/pom.xml. Then trace the requirements-capabilities analysis for the ServiceLoader requirement with cardinality:=multiple; done means the analyzer accepts multiple matching providers without emitting this warning while preserving other checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100