diff options
author | gjoranv <gv@verizonmedia.com> | 2022-09-08 00:29:18 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-09-08 00:29:18 +0200 |
commit | 333894407c0b6b7f12e432b72843487120f51994 (patch) | |
tree | cc28b94f813f9761809e2f160008bb414f97e4f4 /container-core | |
parent | e00663f15d41565c525282930c2983b0f039febd (diff) |
Return Set instead of collection.
Diffstat (limited to 'container-core')
5 files changed, 9 insertions, 11 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java index cbff119c0ba..88e66c45ca3 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java @@ -7,7 +7,6 @@ import com.yahoo.osgi.Osgi; import org.osgi.framework.Bundle; import java.util.ArrayList; -import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -67,8 +66,8 @@ public class ApplicationBundleLoader { readyForNewBundles = false; } - public synchronized Collection<Bundle> completeGeneration(GenerationStatus status) { - Collection<Bundle> ret = List.of(); + public synchronized Set<Bundle> completeGeneration(GenerationStatus status) { + Set<Bundle> ret = Set.of(); if (readyForNewBundles) return ret; readyForNewBundles = true; @@ -85,8 +84,8 @@ public class ApplicationBundleLoader { * Returns the set of bundles that is no longer used by the application, and should therefore be scheduled * for uninstall. */ - private Collection<Bundle> commitBundles() { - Set<Bundle> bundlesToUninstall = new LinkedHashSet<>(obsoleteBundles.values()); + private Set<Bundle> commitBundles() { + var bundlesToUninstall = new LinkedHashSet<>(obsoleteBundles.values()); log.info("Bundles to be uninstalled from previous generation: " + bundlesToUninstall); bundlesFromNewGeneration = Map.of(); @@ -100,12 +99,12 @@ public class ApplicationBundleLoader { * exclusively belongs to the latest (failed) application generation. Uninstalling must * be done by the Deconstructor as they may still be needed by components from the failed gen. */ - private Collection<Bundle> revertToPreviousGeneration() { + private Set<Bundle> revertToPreviousGeneration() { log.info("Reverting to previous generation with bundles: " + obsoleteBundles); log.info("Bundles from latest generation will be removed: " + bundlesFromNewGeneration); activeBundles.putAll(obsoleteBundles); bundlesFromNewGeneration.forEach(activeBundles::remove); - Collection<Bundle> ret = bundlesFromNewGeneration.values(); + var ret = new LinkedHashSet<>(bundlesFromNewGeneration.values()); // For correct operation of the CollisionHook (more specifically its FindHook implementation), the set of // allowed duplicates must reflect the next set of bundles to uninstall, which is now the bundles from the diff --git a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java index f2620cc8baa..e2f97c9ad6b 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java @@ -104,7 +104,7 @@ public class HandlersConfigurerDi { } @Override - public Collection<Bundle> completeBundleGeneration(GenerationStatus status) { + public Set<Bundle> completeBundleGeneration(GenerationStatus status) { return applicationBundleLoader.completeGeneration(status); } } diff --git a/container-core/src/main/java/com/yahoo/container/di/Osgi.java b/container-core/src/main/java/com/yahoo/container/di/Osgi.java index 463ac627a19..d245767120c 100644 --- a/container-core/src/main/java/com/yahoo/container/di/Osgi.java +++ b/container-core/src/main/java/com/yahoo/container/di/Osgi.java @@ -48,7 +48,7 @@ public interface Osgi { * @param status The success or failure of the new generation * @return The set of bundles that are no longer needed by the new or latest good generation. */ - default Collection<Bundle> completeBundleGeneration(GenerationStatus status) { + default Set<Bundle> completeBundleGeneration(GenerationStatus status) { return emptySet(); } diff --git a/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java b/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java index 8a3243ab1a9..e646e916521 100644 --- a/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java +++ b/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java @@ -8,7 +8,6 @@ import org.osgi.framework.Bundle; import java.util.Collection; import java.util.List; -import java.util.Set; import static com.yahoo.container.core.config.BundleTestUtil.BUNDLE_1; import static com.yahoo.container.core.config.BundleTestUtil.BUNDLE_1_REF; diff --git a/container-core/src/test/java/com/yahoo/container/core/config/TestOsgi.java b/container-core/src/test/java/com/yahoo/container/core/config/TestOsgi.java index 2bd3a325d48..dadb35892f7 100644 --- a/container-core/src/test/java/com/yahoo/container/core/config/TestOsgi.java +++ b/container-core/src/test/java/com/yahoo/container/core/config/TestOsgi.java @@ -70,7 +70,7 @@ public class TestOsgi extends MockOsgi implements com.yahoo.container.di.Osgi { } @Override - public Collection<Bundle> completeBundleGeneration(GenerationStatus status) { + public Set<Bundle> completeBundleGeneration(GenerationStatus status) { return bundleLoader.completeGeneration(status); } |