You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Richard Eckart de Castilho (Jira)" <ji...@apache.org> on 2022/09/02 15:21:00 UTC
[jira] [Created] (ARIES-2082) spifly does not properly merge fragment headers
Richard Eckart de Castilho created ARIES-2082:
-------------------------------------------------
Summary: spifly does not properly merge fragment headers
Key: ARIES-2082
URL: https://issues.apache.org/jira/browse/ARIES-2082
Project: Aries
Issue Type: Task
Reporter: Richard Eckart de Castilho
Consider the following situation:
* bundle H is a fragement host
* bundle F1 is a fragment to H and publishes an SPI provider {{osgi.serviceloader;osgi.serviceloader="foo.bar.MySpiProvider"}}
* bundle F2 is a fragment to H and publishes two SPI providers {{osgi.serviceloader;osgi.serviceloader="foo.bar.MySpiProvider", osgi.serviceloader;osgi.serviceloader="foo.bar.MyOtherSpiProvider"}}
When spifly goes through the bundles and fragments, it tries to consider the bundle and the fragments:
Source: ProviderBundleTrackerCustomizer
{noformat}
private String getHeaderFromBundleOrFragment(Bundle bundle, String headerName, String matchString) {
BundleRevision rev = bundle.adapt(BundleRevision.class);
if (rev != null) {
BundleWiring wiring = rev.getWiring();
if (wiring != null) {
for (BundleWire wire : wiring.getProvidedWires("osgi.wiring.host")) {
Bundle fragment = wire.getRequirement().getRevision().getBundle();
Parameters fragmentParameters = new Parameters(fragment.getHeaders().get(headerName));
if (MERGE_HEADERS.contains(headerName)) {
headerParameters.mergeWith(fragmentParameters, false);
}
else {
headerParameters = fragmentParameters;
}
if (matches(headerParameters.toString(), matchString)) {
return headerParameters.toString();
}
}
}
}
}
{noformat}
However, that loop breaks as soon as a first matching header is found. It does not really handle the case of merging all the SPI publishing headers from all the fragments together - so it is rather random which SPIs are actually detected.
Expected behavior:
spifly should be able to find "foo.bar.MySpiProvider" and "foo.bar.MyOtherSpiProvider" irrespective of how the fragment wirings are ordered.
Note that pulling the {{if (matches...)}} out of the loop does also not help - it appears the {{headerParameters.mergeWith(fragmentParameters, false)}} can not properly merge the headers of F1 and F2 either.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)