]> source.dussan.org Git - jgit.git/commitdiff
DirCache: Suppress resource warning related to TemporaryBuffer 77/119377/3
authorDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 01:56:18 +0000 (10:56 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 22:57:02 +0000 (07:57 +0900)
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 <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

index fcee252f805c14591c53848e7932140daf06a308..84bb340d2462bc437cffc99c2dc7675864927329 100644 (file)
@@ -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);