Skip to content

Commit 1478eca

Browse files
ptzieglerHannesWell
authored andcommitted
Inline call to BundleHelper.getPlatformAdmin().getFactory()
As a result of 14f66ae, it might happen that the MinimalState is shut down, even though it was never started. In such a case, the class is implicitly loaded while stopping the plug-in. When loading this class, the "stateObjectFactory" is initialized using the PlatformAdmin provided by the PDE Build bundle. If this bundle is stopped before the PDE Core bundle, an exception is thrown because the PlatformAdmin is no longer available. The BundleHelper is already cached by the PDE Build plug-in and can therefore be called directly, making the "stateObjectFactory" field obsolete. Closes #1714
1 parent 14f66ae commit 1478eca

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.eclipse.osgi.service.resolver.BundleDescription;
5050
import org.eclipse.osgi.service.resolver.State;
5151
import org.eclipse.osgi.service.resolver.StateDelta;
52-
import org.eclipse.osgi.service.resolver.StateObjectFactory;
5352
import org.eclipse.osgi.util.ManifestElement;
5453
import org.eclipse.osgi.util.NLS;
5554
import org.eclipse.pde.core.plugin.IPluginModelBase;
@@ -111,16 +110,10 @@ public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) {
111110

112111
private boolean fNoProfile;
113112

114-
protected static StateObjectFactory stateObjectFactory;
115-
116113
protected String fSystemBundle = IPDEBuildConstants.BUNDLE_OSGI;
117114

118-
static {
119-
stateObjectFactory = BundleHelper.getPlatformAdmin().getFactory();
120-
}
121-
122115
protected MinimalState(MinimalState state) {
123-
this.fState = stateObjectFactory.createState(state.fState);
116+
this.fState = BundleHelper.getPlatformAdmin().getFactory().createState(state.fState);
124117
this.fState.setPlatformProperties(state.fState.getPlatformProperties());
125118
this.fState.setResolver(BundleHelper.getPlatformAdmin().createResolver());
126119
this.fId = state.fId;
@@ -213,8 +206,8 @@ public BundleDescription addBundle(Map<String, String> manifest, File bundleLoca
213206
try {
214207
// OSGi requires a dictionary over any map
215208
Dictionary<String, String> dictionaryManifest = FrameworkUtil.asDictionary(manifest);
216-
BundleDescription descriptor = stateObjectFactory.createBundleDescription(fState, dictionaryManifest,
217-
bundleLocation.getAbsolutePath(), bundleId == -1 ? getNextId() : bundleId);
209+
BundleDescription descriptor = BundleHelper.getPlatformAdmin().getFactory().createBundleDescription(fState,
210+
dictionaryManifest, bundleLocation.getAbsolutePath(), bundleId == -1 ? getNextId() : bundleId);
218211
// new bundle
219212
if (bundleId == -1 || !fState.updateBundle(descriptor)) {
220213
fState.addBundle(descriptor);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2016 IBM Corporation and others.
2+
* Copyright (c) 2005, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -36,6 +36,7 @@
3636
import org.eclipse.osgi.service.resolver.State;
3737
import org.eclipse.pde.core.plugin.IPluginModelBase;
3838
import org.eclipse.pde.core.target.LoadTargetDefinitionJob;
39+
import org.eclipse.pde.internal.build.BundleHelper;
3940
import org.eclipse.pde.internal.core.plugin.ExternalFragmentModel;
4041
import org.eclipse.pde.internal.core.plugin.ExternalPluginModel;
4142
import org.eclipse.pde.internal.core.plugin.ExternalPluginModelBase;
@@ -77,7 +78,7 @@ public PDEState(URI[] target, boolean addResolver, boolean removeDuplicates, IPr
7778
}
7879

7980
private void createNewTargetState(boolean resolve, URI[] uris, IProgressMonitor monitor) {
80-
fState = stateObjectFactory.createState(resolve);
81+
fState = BundleHelper.getPlatformAdmin().getFactory().createState(resolve);
8182
if (resolve) {
8283
final String systemBSN = getSystemBundle();
8384
Comparator<BaseDescription> policy = systemBundlesFirst(systemBSN)

0 commit comments

Comments
 (0)