From b7351facd51aa8e14d4bd2e74e3f4f0b57c55f6f Mon Sep 17 00:00:00 2001 From: Hector Caballero Date: Tue, 4 Sep 2018 11:15:44 -0400 Subject: [PATCH] GC: Avoid logging errors when deleting non-empty folders I88304d34c and Ia555bce00 modified the way errors are handled when trying to delete non-empty reference folders. Before, this error was silently ignored as it was considered an expected output. Now, every failed folder delete is logged which can be noisy. Ignore the DirectoryNotEmptyException but log any other error avoiding deletion of an eligible folder. Signed-off-by: Hector Oswaldo Caballero Change-Id: I194512f67885231d62c03976ae683e5cc450ec7c --- .../src/org/eclipse/jgit/internal/storage/file/GC.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index e4b0a46a30..a4a2baa55b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -54,6 +54,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.nio.channels.Channels; import java.nio.channels.FileChannel; +import java.nio.file.DirectoryNotEmptyException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; @@ -909,6 +910,8 @@ public class GC { private void delete(Path d) { try { Files.delete(d); + } catch (DirectoryNotEmptyException e) { + // Don't log } catch (IOException e) { LOG.error(MessageFormat.format(JGitText.get().cannotDeleteFile, d), e); -- 2.39.5