diff options
author | Arnstein Ressem <aressem@gmail.com> | 2023-01-06 15:09:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 15:09:17 +0100 |
commit | 64e9d534287593e7be365973a5d1084298a65f3e (patch) | |
tree | 25a48348d6af7c15af7ceeefd5f2fb7f9cd07d12 /container-core/src/main/java/com | |
parent | 55fb144ec32fdcdcf42535fcf27d404aece9594b (diff) |
Revert "Improve user friendliness when class resolution fails."
Diffstat (limited to 'container-core/src/main/java/com')
3 files changed, 5 insertions, 63 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 0717ca51dc5..cf3db91239a 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 @@ -3,7 +3,6 @@ package com.yahoo.container.core.config; import com.yahoo.config.FileReference; import com.yahoo.container.di.Osgi.GenerationStatus; -import com.yahoo.jdisc.core.BsnVersion; import com.yahoo.osgi.Osgi; import org.osgi.framework.Bundle; @@ -15,7 +14,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Logger; -import java.util.stream.Collectors; /** * Manages the set of installed and active/inactive bundles. @@ -51,14 +49,6 @@ public class ApplicationBundleLoader { } /** - * Returns bsn:version for all active bundles. - */ - public synchronized List<BsnVersion> activeBundlesBsnVersion() { - return activeBundles.values().stream().map(BsnVersion::new) - .collect(Collectors.toList()); - } - - /** * Installs the given set of bundles and updates state for which bundles and file references * that are active or should be uninstalled in case of success or failure. */ 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 85797444de8..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 @@ -4,7 +4,6 @@ package com.yahoo.container.core.config; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.yahoo.component.AbstractComponent; -import com.yahoo.component.ComponentSpecification; import com.yahoo.component.annotation.Inject; import com.yahoo.component.provider.ComponentRegistry; import com.yahoo.concurrent.ThreadFactoryFactory; @@ -16,24 +15,20 @@ import com.yahoo.container.di.config.SubscriberFactory; import com.yahoo.container.logging.AccessLog; import com.yahoo.filedistribution.fileacquirer.FileAcquirer; import com.yahoo.jdisc.application.OsgiFramework; -import com.yahoo.jdisc.core.BsnVersion; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.service.ClientProvider; import com.yahoo.jdisc.service.ServerProvider; import com.yahoo.osgi.OsgiImpl; import com.yahoo.osgi.OsgiWrapper; import org.osgi.framework.Bundle; -import org.osgi.framework.Version; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; /** * For internal use only. @@ -112,39 +107,6 @@ public class HandlersConfigurerDi { public Set<Bundle> completeBundleGeneration(GenerationStatus status) { return applicationBundleLoader.completeGeneration(status); } - - @Override - protected String bundleResolutionErrorMessage(ComponentSpecification bundleSpec) { - List<BsnVersion> activeBundles = applicationBundleLoader.activeBundlesBsnVersion(); - List<Version> activeVersions = activeVersionsOfBundle(bundleSpec, activeBundles); - - String versionsMessage = ""; - if (activeVersions.size() == 1) { - versionsMessage = "There is an installed bundle with the same name with version: " + activeVersions.get(0); - } else if (activeVersions.size() > 1) { - versionsMessage = "There are installed bundles with the same name with versions: " + activeVersions; - } - if (qualifierIsUsed(bundleSpec, activeVersions)) { - versionsMessage += " Note that qualifier strings must be matched exactly"; - } - return String.format("%s. Installed application bundles: [%s]", - versionsMessage, - activeBundles.stream() - .map(BsnVersion::toReadableString) - .collect(Collectors.joining(", "))); - } - - private static boolean qualifierIsUsed(ComponentSpecification bundleSpec, List<Version> activeVersions) { - return ! bundleSpec.getVersionSpecification().getQualifier().isEmpty() || - activeVersions.stream().anyMatch(version -> ! version.getQualifier().isEmpty()); - } - - private static List<Version> activeVersionsOfBundle(ComponentSpecification bundleSpec, List<BsnVersion> activeBundles) { - return activeBundles.stream() - .filter(bundle -> bundle.symbolicName().equals(bundleSpec.getName())) - .map(BsnVersion::version) - .collect(Collectors.toList()); - } } /** 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 156fa4ab074..2c7a0c2b86b 100644 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java +++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java @@ -62,18 +62,13 @@ public class OsgiImpl implements Osgi { if (bundle != null) { return resolveFromBundle(spec, bundle); } else { - if (jdiscOsgi.isFelixFramework() && ! spec.bundle.equals(spec.classId)) { - // Bundle was explicitly specified, but not found. - throw new IllegalArgumentException("Could not find bundle " + spec.bundle + - ". " + bundleResolutionErrorMessage(spec.bundle)); - } return resolveFromThisBundleOrSystemBundle(spec); } } /** - * Tries to resolve the given class from this class' bundle. - * If unsuccessful, resolves the class from the system bundle (jdisc_core). + * Tries to resolve the given class from this class' bundle classloader. + * If unsuccessful, resolves the class from . */ @SuppressWarnings("unchecked") private Class<Object> resolveFromThisBundleOrSystemBundle(BundleInstantiationSpecification spec) { @@ -91,14 +86,9 @@ public class OsgiImpl implements Osgi { } } throw new IllegalArgumentException( - "Could not create a component with class '" + spec.classId.getName() + - "'. Tried to load class directly, since no bundle was found for spec: " + spec.bundle + - ". " + bundleResolutionErrorMessage(spec.bundle)); - } - - protected String bundleResolutionErrorMessage(ComponentSpecification bundleSpec) { - return " If a bundle with the same name is installed, there is a either a version mismatch " + - "or the installed bundle's version contains a qualifier string."; + "Could not create a component with id '" + spec.classId.getName() + "'. Tried to load class directly, " + + "since no bundle was found for spec: " + spec.bundle + ". If a bundle with the same name is installed, " + + "there is a either a version mismatch or the installed bundle's version contains a qualifier string."); } @SuppressWarnings("unchecked") |