Skip to content

Commit 7e45ebb

Browse files
committed
If JobManager is suspended delay init to a later time
Currently if the JobManager suspended all kind of unwanted effects might happen, especially the joining of a scheduled job will not work but PDE use that here to init the PluginModelManager. The only feasible situation here is to schedule a new job (that will be executed once the manager is enabled again) and then perform the required action. this will the possibly trigger a rebuild if required or notify other listeners.
1 parent 5baaa6d commit 7e45ebb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.eclipse.jdt.core.IClasspathContainer;
2424
import org.eclipse.jdt.core.IJavaProject;
2525
import org.eclipse.jdt.core.JavaCore;
26+
import org.eclipse.jdt.core.JavaModelException;
2627
import org.eclipse.pde.core.plugin.IPluginModelBase;
2728

2829
public class RequiredPluginsInitializer extends ClasspathContainerInitializer {
@@ -36,6 +37,22 @@ public class RequiredPluginsInitializer extends ClasspathContainerInitializer {
3637

3738
@Override
3839
public void initialize(IPath containerPath, IJavaProject javaProject) throws CoreException {
40+
if (Job.getJobManager().isSuspended()) {
41+
// if the jobmanager is currently suspended we can't use the
42+
// schedule/join pattern here, instead we must retry the requested
43+
// action once jobs are enabled again, this will the possibly
44+
// trigger a rebuild if required or notify other listeners.
45+
Job job = Job.create(PDECoreMessages.PluginModelManager_InitializingPluginModels, m -> {
46+
setupClasspath(javaProject);
47+
});
48+
job.setSystem(true);
49+
job.schedule();
50+
} else {
51+
setupClasspath(javaProject);
52+
}
53+
}
54+
55+
protected void setupClasspath(IJavaProject javaProject) throws JavaModelException {
3956
IProject project = javaProject.getProject();
4057
// The first project to be built may initialize the PDE models, potentially long running, so allow cancellation
4158
PluginModelManager manager = PDECore.getDefault().getModelManager();

0 commit comments

Comments
 (0)