[
https://issues.apache.org/jira/browse/FELIX-6015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16737547#comment-16737547
]
Thomas Watson commented on FELIX-6015:
--------------------------------------
I'm still not understanding how your scenario could work. Do you start with a
set of resources that you want to install and then trying to do a resolve
operation to work out additional resources to install? When will you fill in
the actual requirements for the initial resources so that the resolver will be
able to ask the ResolveContext for the additional providers required to resolve
each of the initial resources?
Or are you only supplying a single synthetic resource that requires each
identity from the set of resources you want to install? I don't think that is
it though because you mention the equinox.region and subsystem.core bundles
which are real bundles and the equinox.region bundle is a system bundle
fragment.
> IndexOutOfBoundsException due a missing HostNamespace.HOST_NAMESPACE
> --------------------------------------------------------------------
>
> Key: FELIX-6015
> URL: https://issues.apache.org/jira/browse/FELIX-6015
> Project: Felix
> Issue Type: Bug
> Components: Resolver
> Affects Versions: resolver-1.16.0
> Reporter: Cristiano Gavião
> Priority: Major
>
> When creating a custom ResolveContext we need to build a collection of
> mandatory resources using the method getMandatoryResources().
> Normally we will create such collection using a custom built Resource
> containing only a IdentityNamespace.IDENTITY_NAMESPACE capability, because it
> is enough in order to search for more details of such resource in the
> installed bundles/fragments or in the registered bundle repositories inside
> the findProviders() method.
> The error that I'm getting is due the fact that the resolver, most precisely,
> the Candidates class is using getMandatoryResources() after the
> getInitialCandidates(session) been executed and inferring that it has a
> information about fragments that it doesn't have.
> {code:java}
> public Map<Resource, Resource> getRootHosts()
> {
> Map<Resource, Resource> hosts = new LinkedHashMap<Resource,
> Resource>();
> for (Resource res : *m_session.getMandatoryResources()*)
> {
> addHost(res, hosts);
> }
> for (Resource res : m_session.getOptionalResources())
> {
> if (isPopulated(res)) {
> addHost(res, hosts);
> }
> }
> return hosts;
> }
> {code}
> {code:java}
> private void addHost(Resource res, Map<Resource, Resource> hosts) {
> if (res instanceof WrappedResource)
> {
> res = ((WrappedResource) res).getDeclaredResource();
> }
> if (!Util.isFragment(res))
> {
> hosts.put(res, getWrappedHost(res));
> } else {
> // The error is happening here:
> *Requirement hostReq =
> res.getRequirements(HostNamespace.HOST_NAMESPACE).get(0);*
> Capability hostCap = getFirstCandidate(hostReq);
> // If the resource is an already resolved fragment and can not
> // be attached to new hosts, there will be no matching host,
> // so ignore this resource
> if (hostCap != null) {
> res = getWrappedHost(hostCap.getResource());
> if (res instanceof WrappedResource) {
> hosts.put(((WrappedResource) res).getDeclaredResource(),
> res);
> }
> }
> }
> }
> {code}
> Wouldn't be possible to use the processed initial candidates resources
> instead ?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)