Skip to content

Incompatible with slf4j 2 in OSGi #6406

@msqr

Description

@msqr

Describe the bug
I am trying to deploy micrometer-commons and micrometer-observations in an OSGi environment that includes slf4j 2. Micrometer is compatible with slf4j 2 (#3415) but the OSGi Import-Package version range on the org.slf4j.spi package in micrometer-commons is not.

Environment

  • Micrometer version: 1.15.1
  • Java version: 17

To Reproduce
How to reproduce the bug:

Deploy micrometer-commons in an OSGi container along with slf4j 2. The micrometer bundle cannot be started:

g! ss micro

id	State       Bundle
330	INSTALLED   micrometer-commons_1.15.1

g! diag 330
micrometer-commons [330]
  Unresolved requirement: Import-Package: javax.annotation; version="3.0.2"; resolution:="optional"
  Unresolved requirement: Import-Package: javax.annotation.meta; version="3.0.2"; resolution:="optional"
  Unresolved requirement: Import-Package: org.slf4j.spi; version="[1.7.0,2.0.0)"

g! packages org.slf4j.spi
osgi.wiring.package; bundle-symbolic-name="slf4j.api"; bundle-version:Version="2.0.17"; version:Version="2.0.17"; osgi.wiring.package="org.slf4j.spi"; uses:="org.slf4j,org.slf4j.event,org.slf4j.helpers"<slf4j.api_2.0.17 [309]>
  jcl.over.slf4j_2.0.17 [276] imports
  io.netty.common_4.2.1.Final [158] imports
  org.jboss.logging.jboss-logging_3.1.1.GA [308] imports
  jul.to.slf4j_2.0.17 [236] imports
  org.apache.logging.log4j.slf4j2.impl_2.24.3 [266] imports
g! b 309
slf4j.api_2.0.17 [309]
  Id=309, Status=ACTIVE      Data Root=/var/tmp/org.eclipse.osgi/309/data
  "No registered services."
  Services in use:
    {org.apache.logging.log4j.spi.Provider}={service.id=29, service.bundleid=198, service.scope=singleton, APIVersion=2.6.0}
  Exported packages
    org.slf4j; version="2.0.17"[exported]
    org.slf4j.event; version="2.0.17"[exported]
    org.slf4j.helpers; version="2.0.17"[exported]
    org.slf4j.spi; version="2.0.17"[exported]
    org.slf4j; version="1.7.36"[exported]
    org.slf4j.helpers; version="1.7.36"[exported]
  Imported packages
    org.apache.aries.spifly; version="1.3.7" <org.apache.aries.spifly.dynamic.bundle_1.3.7 [224]>
  No fragment bundles
  No required bundles

Here slf4j 2 exports 1.7.36 versioned packages for all but the org.slf4j.spi package, which causes Micrometer to fail to resolve because of its required version range [1.7,2.0).

Expected behavior
That Micrometer could still resolve and work with version 2 of the org.sfl4j.spi package. This could be achieved by omitting the upper bounds on the org.slf4j.spi package import version range, or increasing it to 3, or omitting the version range completely.

Additional context
For my use case, I was able to get Micrometer deployed by changing the org.slf4j imports to be dynamic, as in this commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA general bugmodule: micrometer-commonAn issue that is related to our common module

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions