Skip to content

Commit 4e3ea4e

Browse files
committed
fix: only increment depth counter for new projects in cycle detection
Fixed bug where currentDepth was unconditionally incremented in beginResolvingProject(), causing potential counter mismatches. Now only increments when project is actually added to processedProjects. Removed redundant cycle checks in calling code since the method now handles duplicate projects correctly on its own.
1 parent 794caaf commit 4e3ea4e

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ private boolean populateWithSavedContainer(IJavaProject project, ContainerResolu
263263
// remove from stack again when done resolving
264264
resolutionContext.endResolvingProject(sourceProject);
265265
}
266+
} else if (LOG.isDebugEnabled()) {
267+
LOG.debug(
268+
"Skipping already processed project '{}' in thread '{}' to avoid cycle",
269+
sourceProject.getName(),
270+
Thread.currentThread().getName());
266271
}
267272
break;
268273
}
@@ -372,7 +377,7 @@ public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEn
372377
// therefore we use a ThreadLocal LinkedHashSet to keep track of recursive attempts
373378
var resolutionContext = currentThreadResolutionContet.get();
374379

375-
// CRITICAL: Check if this is top-level BEFORE incrementing depth
380+
// CRITICAL: Check if this is top-level BEFORE calling beginResolvingProject
376381
// This ensures ThreadLocal cleanup happens correctly
377382
var isTopLevelResolution = resolutionContext.currentDepth == 0;
378383

@@ -386,16 +391,6 @@ public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEn
386391
return new IRuntimeClasspathEntry[0];
387392
}
388393

389-
// Now safe to increment depth counter
390-
if (!resolutionContext.beginResolvingProject(project.getProject())) {
391-
// This should never happen now due to the check above, but keep as safety net
392-
LOG.error(
393-
"Unexpected state: beginResolvingProject returned false after cycle check for project '{}' in thread '{}'",
394-
project.getProject().getName(),
395-
Thread.currentThread().getName());
396-
return new IRuntimeClasspathEntry[0];
397-
}
398-
399394
var stopWatch = StopWatch.startNewStopWatch();
400395
try {
401396
// try the saved container

0 commit comments

Comments
 (0)