]> source.dussan.org Git - jgit.git/commitdiff
[infer] Fix resource leak in BlameCommand 61/87361/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 18 Dec 2016 00:10:25 +0000 (01:10 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 18 Dec 2016 09:38:23 +0000 (10:38 +0100)
Bug: 509385
Change-Id: Ic57fd3bf940752229e35102e7761823f7d3d8732
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java

index a0330c523014fab9aff90f67909e60b8015520ac..2a2e07ddda277d5301e65a964807b0f0b377dd22 100644 (file)
@@ -248,11 +248,12 @@ public class BlameCommand extends GitCommand<BlameResult> {
                        rawText = new RawText(inTree);
                        break;
                case TRUE:
-                       AutoLFInputStream in = new AutoLFInputStream(
-                                       new FileInputStream(inTree), true);
-                       // Canonicalization should lead to same or shorter length
-                       // (CRLF to LF), so the file size on disk is an upper size bound
-                       rawText = new RawText(toByteArray(in, (int) inTree.length()));
+                       try (AutoLFInputStream in = new AutoLFInputStream(
+                                       new FileInputStream(inTree), true)) {
+                               // Canonicalization should lead to same or shorter length
+                               // (CRLF to LF), so the file size on disk is an upper size bound
+                               rawText = new RawText(toByteArray(in, (int) inTree.length()));
+                       }
                        break;
                default:
                        throw new IllegalArgumentException(