So I have this code which I call to update bundles in Apache Felix Framework
during start up, but I only update bundles that I purposely set to level 7 and greater. Whenever this code is executed, the updated bundle is remove from the list and the console hangs. Other times, the updated bundle's status is ACTIVE
but the console also hangs.
Arrays.stream(bundleContext.getBundles())
.filter((bundle) -> return bundle.adapt(BundleStartLevel.class).getStartLevel() > 6;
.forEach((Bundle bundle) -> {
try {
this.logger.log(LOG_DEBUG, "updating : " + bundle.getSymbolicName());
if (bundle.getState() == Bundle.ACTIVE) {
bundle.stop();
}
bundle.update();
bundle.start(Bundle.ACTIVE);
} catch (BundleException exception) {
this.logger.log(LOG_ERROR, "Bundle update for " + name + " failed.", exception);
}
});
Is there a proper way to update bundles in Apache Felix Framework
?
From the description you give and code example it is impossible to tell exactly what goes wrong:
name
.bundle.stop()
and bundle.start()
at all when doing the update. Furthermore, that logic in this code is flawed: if a bundle was not active before it will become so now.start
method of a `BundleActivator, it might try to update itself, which leads to all kinds of unpredictable behaviour.