Skip to content

Commit 7f0b12b

Browse files
laeubimerks
authored andcommitted
Make sure new states assign unique ID to bundles
Currently it can happen that a bundle has an ID clash and then it is missing from a resolve operation afterwards. This now uses the new API to copy a BundleDescription with a specific id to circumvent the problem.
1 parent 9851080 commit 7f0b12b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/BundleValidationOperation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ public void run(IProgressMonitor monitor) throws CoreException {
5757
}
5858
SubMonitor subMonitor = SubMonitor.convert(monitor, fModels.size() + 1);
5959
fState = FACTORY.createState(true);
60+
long id = 1;
6061
for (IPluginModelBase fModel : fModels) {
6162
BundleDescription bundle = fModel.getBundleDescription();
6263
if (bundle != null) {
63-
fState.addBundle(FACTORY.createBundleDescription(bundle));
64+
fState.addBundle(FACTORY.createBundleDescription(id++, bundle));
6465
}
6566
subMonitor.split(1);
6667
}

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.Optional;
4141
import java.util.Queue;
4242
import java.util.Set;
43+
import java.util.concurrent.atomic.AtomicLong;
4344
import java.util.function.BiPredicate;
4445
import java.util.function.Function;
4546
import java.util.function.Predicate;
@@ -580,15 +581,16 @@ private static Set<BundleDescription> reresolveBundlesPreferringIncludedBundles(
580581
launchState.setPlatformProperties(tpState.getPlatformProperties());
581582

582583
// Collect all bundles explicitly included in the launch
584+
AtomicLong id = new AtomicLong(1);
583585
for (IPluginModelBase plugin : includedPlugins) {
584-
addPluginBundle(plugin, launchState, launchBundlePlugins, tpState);
586+
addPluginBundle(plugin, launchState, launchBundlePlugins, tpState, id);
585587
}
586588
Set<BundleDescription> launchBundles = new HashSet<>(launchBundlePlugins.keySet());
587589

588590
// Iterate workspace- and TP-models separately to avoid shadowing of TP models by workspace models
589591
Stream.of(modelManager.getWorkspaceModels(), modelManager.getExternalModels()).flatMap(Arrays::stream) //
590592
.filter(IPluginModelBase::isEnabled).filter(p -> !includedPlugins.contains(p)) //
591-
.forEach(plugin -> addPluginBundle(plugin, launchState, launchBundlePlugins, tpState));
593+
.forEach(plugin -> addPluginBundle(plugin, launchState, launchBundlePlugins, tpState, id));
592594

593595
launchState.getResolver().setSelectionPolicy(Comparator
594596
// prefer bundles explicitly included in the launch
@@ -602,13 +604,13 @@ private static Set<BundleDescription> reresolveBundlesPreferringIncludedBundles(
602604
return launchBundles;
603605
}
604606

605-
private static void addPluginBundle(IPluginModelBase plugin, State launchState, Map<BundleDescription, IPluginModelBase> launchBundlePlugin, State tpState) {
607+
private static void addPluginBundle(IPluginModelBase plugin, State launchState, Map<BundleDescription, IPluginModelBase> launchBundlePlugin, State tpState, AtomicLong id) {
606608
BundleDescription bundle = plugin.getBundleDescription();
607609
if (bundle != null) {
608610
if (bundle.getContainingState() != tpState) { // consistency check
609611
throw new IllegalStateException("Plugins have different TP state"); //$NON-NLS-1$
610612
}
611-
BundleDescription launchBundle = launchState.getFactory().createBundleDescription(bundle);
613+
BundleDescription launchBundle = launchState.getFactory().createBundleDescription(id.getAndIncrement(), bundle);
612614
launchBundle.setUserObject(plugin);
613615
if (!launchState.addBundle(launchBundle)) {
614616
throw new IllegalStateException("Failed to add bundle to launch state: " + launchBundle); //$NON-NLS-1$

0 commit comments

Comments
 (0)