diff options
author | gjoranv <gv@verizonmedia.com> | 2020-07-15 12:52:19 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2020-07-15 12:52:19 +0200 |
commit | 1da1e3b3a9189e4fdff2ecd1b96210818896f3cc (patch) | |
tree | 79ed6046a5e73650ccca7fbb692b6039e161b966 /container-core | |
parent | 72eb7a8938f60b6c3c7a562673514414bcb1b106 (diff) |
Don't throw when using a test osgi framework
- ClassloaderOsgiFramework returns all installed bundles upon
each call to install().
Diffstat (limited to 'container-core')
3 files changed, 13 insertions, 1 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/BundleManager.java b/container-core/src/main/java/com/yahoo/container/core/config/BundleManager.java index 3727da66b63..fcbadcc1535 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/BundleManager.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/BundleManager.java @@ -106,7 +106,10 @@ public class BundleManager { try { log.info("Installing bundle with reference '" + reference.value() + "'"); List<Bundle> bundles = bundleInstaller.installBundles(reference, osgi); - if (bundles.size() > 1) { + + // Throw if more than one bundle was installed, which means that the X-JDisc-Preinstall-Bundle header was used. + // However, if the OSGi framework is only a test framework, this rule does not apply. + if (bundles.size() > 1 && osgi.hasFelixFramework()) { throw new RuntimeException("Bundle '" + bundles.get(0).getSymbolicName() + "' tried to pre-install other bundles."); } reference2Bundle.put(reference, bundles.get(0)); diff --git a/container-core/src/main/java/com/yahoo/osgi/Osgi.java b/container-core/src/main/java/com/yahoo/osgi/Osgi.java index 2198bbc8476..2b638d50f45 100644 --- a/container-core/src/main/java/com/yahoo/osgi/Osgi.java +++ b/container-core/src/main/java/com/yahoo/osgi/Osgi.java @@ -23,4 +23,7 @@ public interface Osgi { void allowDuplicateBundles(Collection<Bundle> bundles); + default boolean hasFelixFramework() { + return false; + } } diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java index c0c0135f634..6884b3c46c0 100644 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java +++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java @@ -5,6 +5,7 @@ import com.yahoo.component.ComponentSpecification; import com.yahoo.component.Version; import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.jdisc.application.OsgiFramework; +import com.yahoo.jdisc.core.FelixFramework; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; import org.osgi.framework.launch.Framework; @@ -150,6 +151,11 @@ public class OsgiImpl implements Osgi { jdiscOsgi.allowDuplicateBundles(bundles); } + @Override + public boolean hasFelixFramework() { + return jdiscOsgi instanceof FelixFramework; + } + private static Bundle firstNonFrameworkBundle(List<Bundle> bundles) { for (Bundle b : bundles) { if (! (b instanceof Framework)) |