[infer] Fix resource leak in BlameCommand

Bug: 509385
Change-Id: Ic57fd3bf940752229e35102e7761823f7d3d8732
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2016-12-18 01:10:25 +01:00
parent 075e55fa28
commit 05e8cdf563
1 changed files with 6 additions and 5 deletions

View File

@ -248,11 +248,12 @@ private RawText getRawText(File inTree) throws IOException,
rawText = new RawText(inTree); rawText = new RawText(inTree);
break; break;
case TRUE: case TRUE:
AutoLFInputStream in = new AutoLFInputStream( try (AutoLFInputStream in = new AutoLFInputStream(
new FileInputStream(inTree), true); new FileInputStream(inTree), true)) {
// Canonicalization should lead to same or shorter length // Canonicalization should lead to same or shorter length
// (CRLF to LF), so the file size on disk is an upper size bound // (CRLF to LF), so the file size on disk is an upper size bound
rawText = new RawText(toByteArray(in, (int) inTree.length())); rawText = new RawText(toByteArray(in, (int) inTree.length()));
}
break; break;
default: default:
throw new IllegalArgumentException( throw new IllegalArgumentException(