summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2019-10-29 16:03:15 +0100
committergjoranv <gv@verizonmedia.com>2019-10-29 16:03:15 +0100
commit7ce5237be211f5c110217acd10e452e0fc9af17f (patch)
treea4e738667d8df6bdacc0fff73282bd33acfaa973 /container-core
parente4b63a6309e92161d2c879e920410b75c74e899a (diff)
Rename retainOnly and extract helper method.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java
index 9115a51b486..4b8f21469d1 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java
@@ -147,9 +147,10 @@ public class BundleLoader {
}
/**
- * Returns the bundles to schedule for uninstall after their components have been deconstructed.
+ * Returns the bundles to schedule for uninstall after their components have been deconstructed
+ * and removes the same bundles from the map of active bundles.
*/
- private Set<Bundle> retainOnly(List<FileReference> newReferences) {
+ private Set<Bundle> getBundlesToUninstall(List<FileReference> newReferences) {
Set<Bundle> bundlesToRemove = new HashSet<>(osgi.getCurrentBundles());
for (FileReference fileReferenceToKeep: newReferences) {
@@ -158,24 +159,27 @@ public class BundleLoader {
}
bundlesToRemove.removeAll(osgi.getInitialBundles());
+ removeInactiveFileReferences(newReferences);
+ return bundlesToRemove;
+ }
+
+ private void removeInactiveFileReferences(List<FileReference> newReferences) {
// Clean up the map of active bundles
Set<FileReference> fileReferencesToRemove = new HashSet<>(reference2Bundles.keySet());
fileReferencesToRemove.removeAll(newReferences);
fileReferencesToRemove.forEach(reference2Bundles::remove);
-
- return bundlesToRemove;
}
/**
* Installs the given set of bundles and returns the set of bundles that is no longer used
* by the application, and should therefore be scheduled for uninstall.
*/
- public synchronized Set<Bundle> use(List<FileReference> bundles) {
- Set<Bundle> bundlesToUninstall = retainOnly(bundles);
+ public synchronized Set<Bundle> use(List<FileReference> newBundles) {
+ Set<Bundle> bundlesToUninstall = getBundlesToUninstall(newBundles);
osgi.allowDuplicateBundles(bundlesToUninstall);
log.info(() -> bundlesToUninstall.isEmpty() ? "Adding bundles to allowed duplicates: " + bundlesToUninstall : "");
- install(bundles);
+ install(newBundles);
startBundles();
log.info(installedBundlesMessage());