From 7bd2a4a7c60d183b26b59995063a38f5573112ec Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 14 Mar 2018 10:56:18 +0900 Subject: [PATCH] DirCache: Suppress resource warning related to TemporaryBuffer In #writeTo, the TemporaryBuffer can't be opened in try-with-resource because it's referenced in the finally block. Instead it is explicitly closed within the try block. Suppress the warning with an explanatory comment. Change-Id: I02009f77f9630d5d55afc34eb86d304ff103b8b0 Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index fcee252f80..84bb340d24 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -702,6 +702,8 @@ public class DirCache { } if (writeTree) { + @SuppressWarnings("resource") // Explicitly closed in try block, and + // destroyed in finally TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20); try { tree.write(tmp, bb); -- 2.39.5