summaryrefslogtreecommitdiffstats
path: root/jdisc_core
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2022-08-24 16:00:35 +0200
committergjoranv <gv@verizonmedia.com>2022-08-25 17:34:02 +0200
commitb0a398eaeadfaf12e31bcfef2e41892439db1149 (patch)
tree34f6d7bf053cb8fb31cfd9b73e37e979bd392a39 /jdisc_core
parentc05ab2660c017cb54ee9a591e2e02434e78bd176 (diff)
Clean up bundles and allowed duplicates after a failed reconfig.
Diffstat (limited to 'jdisc_core')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java2
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java7
2 files changed, 4 insertions, 5 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java
index 438ad8d8ebe..f8c158ab178 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java
@@ -94,7 +94,7 @@ public interface OsgiFramework {
* Allows this framework to install duplicates of the given collection of bundles. Duplicate detection
* is handled by the {@link com.yahoo.jdisc.core.BundleCollisionHook}.
*
- * @param bundles The bundles to allow duplicates of
+ * @param bundles The bundles to allow duplicates of. An empty collection will prohibit any duplicates.
*/
void allowDuplicateBundles(Collection<Bundle> bundles);
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java
index 2f90b4e067f..3212bb4e6de 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java
@@ -34,7 +34,7 @@ public class BundleCollisionHook implements CollisionHook, EventHook, FindHook {
private static final Logger log = Logger.getLogger(BundleCollisionHook.class.getName());
private ServiceRegistration<?> registration;
- private Map<Bundle, BsnVersion> allowedDuplicates = new HashMap<>(5);
+ private final Map<Bundle, BsnVersion> allowedDuplicates = new HashMap<>(5);
public void start(BundleContext context) {
if (registration != null) {
@@ -50,11 +50,10 @@ public class BundleCollisionHook implements CollisionHook, EventHook, FindHook {
}
/**
- * Adds a collection of bundles to the allowed duplicates.
- * Also clears any previous allowed duplicates of the new allowed duplicates.
+ * Sets a collection of bundles to allow duplicates for.
*/
synchronized void allowDuplicateBundles(Collection<Bundle> bundles) {
- allowedDuplicates.values().removeAll(bundles.stream().map(BsnVersion::new).collect(Collectors.toSet()));
+ allowedDuplicates.clear();
for (var bundle : bundles) {
allowedDuplicates.put(bundle, new BsnVersion(bundle));
}