From dcf62f2cb2b3d4bc2384b8103ccf72f5a38e4dae Mon Sep 17 00:00:00 2001 From: Peter Laird Date: Thu, 30 Apr 2020 14:33:57 -0600 Subject: [PATCH] limit the times diagnostics will be reported for #113 --- .../eclipse/classpath/BazelClasspathContainer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin-core/src/main/java/com/salesforce/bazel/eclipse/classpath/BazelClasspathContainer.java b/plugin-core/src/main/java/com/salesforce/bazel/eclipse/classpath/BazelClasspathContainer.java index 3cf3d843..00547c38 100644 --- a/plugin-core/src/main/java/com/salesforce/bazel/eclipse/classpath/BazelClasspathContainer.java +++ b/plugin-core/src/main/java/com/salesforce/bazel/eclipse/classpath/BazelClasspathContainer.java @@ -487,12 +487,16 @@ private IPath getJarPathOnDisk(File bazelOutputBase, File bazelExecRoot, String // resolving the link will fail if the symlink does not a point to a real file path = Files.readSymbolicLink(path); } catch (IOException ex) { + // TODO this can happen if someone does a 'bazel clean' using the command line #113 + // https://github.com/salesforce/bazel-eclipse/issues/113 BazelPluginActivator.error("Problem adding jar to project ["+eclipseProjectName+"] because it does not exist on the filesystem: "+path); printDirectoryDiagnostics(path.toFile().getParentFile().getParentFile(), " "); } } else { // it is a normal path, check for existence if (!Files.exists(path)) { + // TODO this can happen if someone does a 'bazel clean' using the command line #113 + // https://github.com/salesforce/bazel-eclipse/issues/113 BazelPluginActivator.error("Problem adding jar to project ["+eclipseProjectName+"] because it does not exist on the filesystem: "+path); printDirectoryDiagnostics(path.toFile().getParentFile().getParentFile(), " "); } @@ -528,8 +532,15 @@ private void addProjectReference(IProject thisProject, IProject thatProject) { } - + private static int diagnosticsCount = 0; private static void printDirectoryDiagnostics(File path, String indent) { + if (diagnosticsCount > 3) { + // only do this a few times so we know there are problems but then be silent, + // otherwise a shutdown with lots of projects open can take forever + return; + } + diagnosticsCount++; + File[] children = path.listFiles(); System.out.println(indent+BazelProjectHelper.getCanonicalPathStringSafely(path)); if (children != null) {