Description
When I tried Concierge with own launcher I found out that BundleContext.getBundle(String)
does not work correctly when the framework uses an existing storage.
Basically the scenario follows this pseudocode:
Framework framework = factory.newFramework(properties); // Here the path to the storage is set
framework.init();
BundleContext systemBundle = framework.getBundleContext();
Bundle bundle = systemBundle.getBundle(location);
if (bundle == null) {
try (InputStream is = open(location)) {
bundle = systemBundle.installBundle(location, is);
}
}
The bundle
variable is always null
, while it should return the installed bundle when the code is run second time with the same storage. I tried replacing getBundle
with something like:
Bundle bundle = Stream.of(systemBundle.getBundles())
.filter(b -> location.equals(b.getLocation())
.findAny()
.orElse(null);
And this always works. So the framework apparently knows which bundles were installed, it just does not update its structures for getBundle
to work properly.
The described behavior of getBundle
in this use case results in duplicated installation of the bundle – and what is even more interesting: the newly installed bundle has the same location as the existing bundle. I believe this is wrong as well and the location should be unique. Maybe the framework implementation fails to check the location duplicity for the same reason.