From 7ce5237be211f5c110217acd10e452e0fc9af17f Mon Sep 17 00:00:00 2001 From: gjoranv Date: Tue, 29 Oct 2019 16:03:15 +0100 Subject: Rename retainOnly and extract helper method. --- .../com/yahoo/container/core/config/BundleLoader.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'container-core/src/main/java/com') 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 retainOnly(List newReferences) { + private Set getBundlesToUninstall(List newReferences) { Set 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 newReferences) { // Clean up the map of active bundles Set 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 use(List bundles) { - Set bundlesToUninstall = retainOnly(bundles); + public synchronized Set use(List newBundles) { + Set bundlesToUninstall = getBundlesToUninstall(newBundles); osgi.allowDuplicateBundles(bundlesToUninstall); log.info(() -> bundlesToUninstall.isEmpty() ? "Adding bundles to allowed duplicates: " + bundlesToUninstall : ""); - install(bundles); + install(newBundles); startBundles(); log.info(installedBundlesMessage()); -- cgit v1.2.3