Fix overflow stream leak during merge conflicts

When reading back from an overflowed TemporaryBuffer the InputStream
must be closed to close the FileInputStream that is reading from
the backing file.

Change-Id: Id83d8f16f5b2c2618a9f841ec3508508455a6ae1
This commit is contained in:
Shawn Pearce 2015-04-01 12:57:06 -07:00
parent 6884ea24cd
commit e4433e5e37
1 changed files with 3 additions and 2 deletions

View File

@ -810,8 +810,9 @@ private ObjectId insertMergeResult(MergeResult<RawText> result)
new MergeFormatter().formatMerge(buf, result,
Arrays.asList(commitNames), CHARACTER_ENCODING);
buf.close();
return getObjectInserter().insert(OBJ_BLOB, buf.length(),
buf.openInputStream());
try (InputStream in = buf.openInputStream()) {
return getObjectInserter().insert(OBJ_BLOB, buf.length(), in);
}
} finally {
buf.destroy();
}