[ https://issues.apache.org/jira/browse/FELIX-6015?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cristiano Gavião resolved FELIX-6015. ------------------------------------- Resolution: Invalid > 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)