diff options
author | Sebastian Ratz | 2019-04-01 17:28:33 +0000 |
---|---|---|
committer | Sebastian Ratz | 2019-04-01 17:28:33 +0000 |
commit | d2b521ea4ddf42bf8c7f87d513a601b1277ed9a1 (patch) | |
tree | 4308d7ef6a29263dd30a2c81a830eec26e55abf3 | |
parent | 09875113dad3b6964b756749fa54378c1e3520c7 (diff) | |
download | eclipse.platform.runtime-d2b521ea4ddf42bf8c7f87d513a601b1277ed9a1.tar.gz eclipse.platform.runtime-d2b521ea4ddf42bf8c7f87d513a601b1277ed9a1.tar.xz eclipse.platform.runtime-d2b521ea4ddf42bf8c7f87d513a601b1277ed9a1.zip |
Bug 544423 - Resolve usage of deprecated PackageAdminI20190403-1800I20190402-1800I20190401-1800
Fix getHosts() by calling BundleWiring#getRequiredWires() again.
Change-Id: I70d1e7966e5894e8741b9eeda43ab40c8cd4722d
Signed-off-by: Sebastian Ratz <sebastian.ratz@sap.com>
-rw-r--r-- | bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java index eeda2b813..53f01b021 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java @@ -19,7 +19,6 @@ import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.util.*; -import java.util.function.Function; import org.eclipse.core.internal.preferences.exchange.ILegacyPreferences; import org.eclipse.core.internal.preferences.exchange.IProductPreferencesService; import org.eclipse.core.internal.preferences.legacy.InitLegacyPreferences; @@ -284,23 +283,31 @@ public final class InternalPlatform { } public Bundle[] getFragments(Bundle bundle) { - return getWiredBundles(bundle, (wire) -> wire.getRequirer().getBundle()); + BundleWiring wiring = bundle.adapt(BundleWiring.class); + if (wiring == null) { + return null; + } + List<BundleWire> hostWires = wiring.getProvidedWires(HostNamespace.HOST_NAMESPACE); + if (hostWires == null) { + // we don't hold locks while checking the graph, just return if no longer valid + return null; + } + Bundle[] result = hostWires.stream().map(wire -> wire.getRequirer().getBundle()).filter(Objects::nonNull) + .toArray(Bundle[]::new); + return result.length > 0 ? result : null; } public Bundle[] getHosts(Bundle bundle) { - return getWiredBundles(bundle, (wire) -> wire.getProvider().getBundle()); - } - - private Bundle[] getWiredBundles(Bundle bundle, Function<BundleWire, Bundle> wireToBundleMapper) { BundleWiring wiring = bundle.adapt(BundleWiring.class); - List<BundleWire> hostWires = wiring != null ? wiring.getProvidedWires(HostNamespace.HOST_NAMESPACE) - : null; - + if (wiring == null) { + return null; + } + List<BundleWire> hostWires = wiring.getRequiredWires(HostNamespace.HOST_NAMESPACE); if (hostWires == null) { // we don't hold locks while checking the graph, just return if no longer valid return null; } - Bundle[] result = hostWires.stream().map(wireToBundleMapper).filter(Objects::nonNull) + Bundle[] result = hostWires.stream().map(wire -> wire.getProvider().getBundle()).filter(Objects::nonNull) .toArray(Bundle[]::new); return result.length > 0 ? result : null; } |