Skip to content

Commit 4e422b1

Browse files
authored
Fix counter bug (#52)
1 parent 9e21eb0 commit 4e422b1

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,24 @@ public void add(IRuntimeClasspathEntry runtimeClasspathEntry) {
6363
}
6464

6565
/**
66+
* Begins the resolution of a project if the project was never processed before.
67+
* <p>
68+
* When this method returns <code>true</code>, a matching call to {@link #endResolvingProject(IProject)} must be
69+
* made.
70+
* </p>
71+
*
6672
* @param project
6773
* the project being resolved
68-
* @return <code>true</code> if the project was never processed before, <code>false</code> otherwise
74+
* @return <code>true</code> if the project was never processed before and resolution is tracked,
75+
* <code>false</code> otherwise
6976
*/
70-
public boolean beginResolvingProject(IProject project) {
71-
currentDepth++;
72-
return processedProjects.add(project);
77+
public boolean beginResolvingProjectIfNeverProcessedBefore(IProject project) {
78+
if (processedProjects.add(project)) {
79+
currentDepth++;
80+
return true;
81+
}
82+
83+
return false;
7384
}
7485

7586
public void endResolvingProject(IProject project) {
@@ -232,7 +243,7 @@ private boolean populateWithSavedContainer(IJavaProject project, ContainerResolu
232243
case IClasspathEntry.CPE_PROJECT: {
233244
// projects need to be resolved properly so we have all the output folders and exported jars on the classpath
234245
var sourceProject = workspaceRoot.getProject(e.getPath().segment(0));
235-
if (resolutionContext.beginResolvingProject(sourceProject)) {
246+
if (resolutionContext.beginResolvingProjectIfNeverProcessedBefore(sourceProject)) {
236247
try {
237248
// only resolve and add the projects if it was never attempted before
238249
populateWithResolvedProject(sourceProject, resolutionContext);
@@ -289,7 +300,7 @@ public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEn
289300
// this method can be entered recursively; luckily only within the same thread
290301
// therefore we use a ThreadLocal LinkedHashSet to keep track of recursive attempts
291302
var resolutionContext = currentThreadResolutionContet.get();
292-
if (!resolutionContext.beginResolvingProject(project.getProject())) {
303+
if (!resolutionContext.beginResolvingProjectIfNeverProcessedBefore(project.getProject())) {
293304
LOG.warn(
294305
"Detected recursive resolution attempt for project '{}' in thread '{}' ({})",
295306
project.getProject().getName(),

0 commit comments

Comments
 (0)