Skip to content

Bundle containing ServiceLoader consumer where there are multiple providers are throwing warnings #306

@royteeuwen

Description

@royteeuwen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions