Skip to content

Commit 700e1c6

Browse files
committed
Print a stack dump if initialize is called outside of Initializing Java
Currently one would expect that all calls to initialize the classpath originate from the "Initializing Java Tooling" job, but it happens to be not always the case. If that happens early access to the classpath might lead to unexpected rebuilds or other issues. This now enhance the tracing to provide a stacktrace in this case to make it more clear where the call is coming from to allow analysis and possible mitigation.
1 parent e95532e commit 700e1c6

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,19 @@ protected IStatus run(IProgressMonitor jobMonitor) {
129129
if (monitor.isCanceled()) {
130130
return Status.CANCEL_STATUS;
131131
}
132-
if (!updateProjects.isEmpty()) {
132+
if (updateProjects.isEmpty()) {
133+
if (PDECore.DEBUG_STATE) {
134+
PDECore.TRACE.trace(PDECore.KEY_DEBUG_STATE,
135+
"UpdateClasspathsJob finished, but no project needs an update!"); //$NON-NLS-1$
136+
}
137+
} else {
133138
int i = 0;
134139
int n = updateProjects.size();
140+
if (PDECore.DEBUG_STATE) {
141+
PDECore.TRACE.trace(PDECore.KEY_DEBUG_STATE, String
142+
.format("UpdateClasspathsJob finished, there are %d project that need a classpath container update.", //$NON-NLS-1$
143+
n));
144+
}
135145
IJavaProject[] javaProjects = new IJavaProject[n];
136146
IClasspathContainer[] container = new IClasspathContainer[n];
137147
for (Entry<IJavaProject, IClasspathContainer> entry : updateProjects.entrySet()) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ public class RequiredPluginsInitializer extends ClasspathContainerInitializer {
3030
public void initialize(IPath containerPath, IJavaProject javaProject) throws CoreException {
3131
IProject project = javaProject.getProject();
3232
IClasspathContainer savedState = ClasspathContainerState.readState(project);
33+
if (PDECore.DEBUG_STATE) {
34+
// This should at best only ever be called from the "Initializing
35+
// Java Tooling" job, if that is not the case something might be
36+
// wrong and we add a stackdump to give more information about the
37+
// source
38+
if (!Thread.currentThread().getName().contains("Initializing Java Tooling")) { //$NON-NLS-1$
39+
PDECore.TRACE.traceDumpStack(PDECore.KEY_DEBUG_STATE);
40+
}
41+
}
3342
ClasspathContainerState.setProjectContainers(new IJavaProject[] { javaProject },
3443
new IClasspathContainer[] { savedState }, null);
3544
// The saved state might be stale, request a classpath update here, this

0 commit comments

Comments
 (0)