Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3618

[Framework] Should not allow bundles to use generic cap/req headers for osgi.wiring.* namespaces

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: framework-4.0.3
    • Fix Version/s: framework-4.2.0
    • Component/s: Framework
    • Labels:
      None

      Description

      I think I found a bug while I playing with 4.3's Bundle Capabilities.

      I tried to convert a simple Export-Package to Provide-Capability.

      Core specification 5.0, §3.3.3 defines the grammar for Provide-Compatibility headers:Provide-Capability ::= capability ( ',' capability )*
      capability ::= name-space
      ( ’;’ directive | typed-attr )*
      name-space ::= symbolic-name
      typed-attr ::= extended ( ’:’ type ) ’=’ argument
      type ::= scalar | list
      scalar ::= ’String’ | ’Version’ | ’Long’

      ’Double’
      list ::= ’List<’ scalar ’>’

      With my interpretation of the spec:

      Export-Package: com.test.api; version="1.0.0"

      becomes:

      Provide-Capability: osgi.wiring.package; osgi.wiring.package=com.test.api; version:Version=1.0.0

      where osgi.wiring.package is both the namespace and the attribute name for the package name. Please note that the namespace is mandatory.

      This is consistent with the Require-Capability statement:
      osgi.wiring.package; (&(osgi.wiring.package=com.test.api)(version>=1.0.0)(!(version>=2.0.0))) resolved by:
      osgi.wiring.package; com.test.api 1.0.0 from com.test.api [41]

      If I use this header and install my bundle, using Felix 4.0.3 I get:

      g! inspect c * 41
      com.test.api [41] provides:
      -------------------------------
      osgi.wiring.bundle; com.test.api 1.0.0 [UNUSED]
      osgi.wiring.host; com.test.api 1.0.0 [UNUSED]
      osgi.wiring.package; com.test.api 1.0.0 required by:
      com.test.consumer [36]
      osgi.wiring.package; com.test.api 1.0.0 [UNUSED]
      g!

      Note that the same package is advised as exported twice by the bundle with only the first one wired.

      Now, if I use Export-Package, it is exported just once as expected,
      The only way with Provide-Capability to get it exported just once is to omit the namespace, as in:

      Provide-Capability: osgi.wiring.package=com.test.api; version:Version=1.0.0

      However, this is not compliant with the spec, since the namespace is mandatory.

      Finally, a last test where the namespace osgi.wiring.package has no attributes or directives fail with a NullPointerException, it should probably be handled gracefully.
      Provide-Capability: osgi.wiring.package

      Stacktrace:
      g! start 62
      ERROR: Unable to resolve 62.0 (java.lang.NullPointerException)
      java.lang.NullPointerException
      at org.apache.felix.framework.BundleWiringImpl.<init>(BundleWiringImpl.java:270)
      at org.apache.felix.framework.StatefulResolver.markResolvedRevisions(StatefulResolver.java:650)
      at org.apache.felix.framework.StatefulResolver.resolve(StatefulResolver.java:189)
      at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3819)
      at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
      at org.apache.felix.gogo.command.Basic.start(Basic.java:729)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        Attachments

          Activity

            People

            • Assignee:
              rickhall Richard S. Hall
              Reporter:
              magnet Simon Chemouil
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: