From 94ff6e92fa1e3fe39b1cc90d9ddfcac2e3c08cfe Mon Sep 17 00:00:00 2001 From: Gunnar Wagenknecht Date: Fri, 2 Jan 2026 15:01:18 +0100 Subject: [PATCH] Fix counter bug --- ...azelClasspathContainerRuntimeResolver.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java index a74c3fcb..d7051bda 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/classpath/BazelClasspathContainerRuntimeResolver.java @@ -63,13 +63,24 @@ public void add(IRuntimeClasspathEntry runtimeClasspathEntry) { } /** + * Begins the resolution of a project if the project was never processed before. + *

+ * When this method returns true, a matching call to {@link #endResolvingProject(IProject)} must be + * made. + *

+ * * @param project * the project being resolved - * @return true if the project was never processed before, false otherwise + * @return true if the project was never processed before and resolution is tracked, + * false otherwise */ - public boolean beginResolvingProject(IProject project) { - currentDepth++; - return processedProjects.add(project); + public boolean beginResolvingProjectIfNeverProcessedBefore(IProject project) { + if (processedProjects.add(project)) { + currentDepth++; + return true; + } + + return false; } public void endResolvingProject(IProject project) { @@ -232,7 +243,7 @@ private boolean populateWithSavedContainer(IJavaProject project, ContainerResolu case IClasspathEntry.CPE_PROJECT: { // projects need to be resolved properly so we have all the output folders and exported jars on the classpath var sourceProject = workspaceRoot.getProject(e.getPath().segment(0)); - if (resolutionContext.beginResolvingProject(sourceProject)) { + if (resolutionContext.beginResolvingProjectIfNeverProcessedBefore(sourceProject)) { try { // only resolve and add the projects if it was never attempted before populateWithResolvedProject(sourceProject, resolutionContext); @@ -289,7 +300,7 @@ public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEn // this method can be entered recursively; luckily only within the same thread // therefore we use a ThreadLocal LinkedHashSet to keep track of recursive attempts var resolutionContext = currentThreadResolutionContet.get(); - if (!resolutionContext.beginResolvingProject(project.getProject())) { + if (!resolutionContext.beginResolvingProjectIfNeverProcessedBefore(project.getProject())) { LOG.warn( "Detected recursive resolution attempt for project '{}' in thread '{}' ({})", project.getProject().getName(),