[
https://issues.apache.org/jira/browse/ARIES-1416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14903034#comment-14903034
]
John Ross commented on ARIES-1416:
----------------------------------
ARIES-1397 introduced an optimization into the preferred provider repository
where the validity check invokes the contains method of the parent constituents
collection rather than using the ResourceHelper, which compares resources based
on their osgi.identity capabilities.
I was able to reproduce this issue in a test case with the following structure.
Bundle-SymbolicName: bundle.a.jar
Require-Capability: b
Bundle-SymbolicName: bundle.b.jar
Provide-Capability: b
Subsystem-SymbolicName: application.a.esa
Subsystem-Content: bundle.a.jar
Subsystem-Type: osgi.subsystem.application;provision-policy:=rejectDependencies
Preferred-Provider: bundle.b.jar
(include bundle.b.jar in the archive but not as content)
(1) Install bundle B into the root subsystem's region.
(2) Install application A as a child of the root subsystem.
Dependencies are selected in the following order: content repository, preferred
provider repository, system repository, local repository, and repository
services. Note that bundle B is in the preferred provider, system, and local
repositories. Bundle B is seen in the preferred provider repository but because
it comes from the system repository it must be a constituent of application A's
parent (i.e. the root subsystem). In actuality it is but fails the contains
check because the capability resource is a BundleRevision whereas the
constituent is a BundleResourceInstaller$BundleConstituent. Capabilities are
selected from the preferred repository (basically a composite) in the following
order: system repository, local repository, and repository services. Because
the implementation thinks there is no valid preferred provider in the system
repository, it moves on to the local repository and finds one. It then tries to
install bundle B as a dependency into the root subsystem region (because
application A is rejectDependencies) where it already exists.
The solution was to wrap a BundleRevision with a
BundleResourceInstaller$BundleConstituent before performing the contains check.
Note that the isValid method will only be called for capabilities from the
system repository, meaning that the underlying resource will always be either a
BasicSubsystem or BundleRevision.
> BundleException "bundle is already installed" when the Preferred-Provider
> subsystem header points to a bundle.
> --------------------------------------------------------------------------------------------------------------
>
> Key: ARIES-1416
> URL: https://issues.apache.org/jira/browse/ARIES-1416
> Project: Aries
> Issue Type: Bug
> Components: Subsystem
> Reporter: John Ross
> Assignee: John Ross
>
> When using the Preferred-Provider header that specifies a bundle, an
> exception similar to the following is received:
> org.osgi.framework.BundleException: A bundle is already installed with the
> name "bundle.c.jar" and version "0.0.0"
> at
> org.eclipse.osgi.container.ModuleContainer.install(ModuleContainer.java:254)
> at org.eclipse.osgi.storage.Storage.install(Storage.java:513)
> at
> org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:146)
> at
> org.eclipse.equinox.internal.region.BundleIdBasedRegion.installBundle0(BundleIdBasedRegion.java:117)
> at
> org.eclipse.equinox.internal.region.BundleIdBasedRegion.installBundleAtLocation(BundleIdBasedRegion.java:97)
> at
> org.apache.aries.subsystem.core.internal.BundleResourceInstaller.installBundle(BundleResourceInstaller.java:197)
> at
> org.apache.aries.subsystem.core.internal.BundleResourceInstaller.install(BundleResourceInstaller.java:182)
> at
> org.apache.aries.subsystem.core.internal.SubsystemResourceInstaller.installAriesSubsystem(SubsystemResourceInstaller.java:98)
> at
> org.apache.aries.subsystem.core.internal.SubsystemResourceInstaller.installSubsystemResource(SubsystemResourceInstaller.java:159)
> at
> org.apache.aries.subsystem.core.internal.SubsystemResourceInstaller.installRawSubsystemResource(SubsystemResourceInstaller.java:130)
> at
> org.apache.aries.subsystem.core.internal.SubsystemResourceInstaller.install(SubsystemResourceInstaller.java:38)
> at
> org.apache.aries.subsystem.core.internal.SubsystemResourceInstaller.installAriesSubsystem(SubsystemResourceInstaller.java:113)
> at
> org.apache.aries.subsystem.core.internal.SubsystemResourceInstaller.install(SubsystemResourceInstaller.java:36)
> at
> org.apache.aries.subsystem.core.internal.InstallAction.run(InstallAction.java:77)
> at
> org.apache.aries.subsystem.core.internal.InstallAction.run(InstallAction.java:30)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:646)
> at
> org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:690)
> at
> org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:278)
> at
> org.apache.aries.subsystem.core.internal.BasicSubsystem.install(BasicSubsystem.java:65)
> ...
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)