[infer] Fix resource leaks in DfsInserter
Bug: 509385 Change-Id: Id5dc40bb3fb9da97ea0795cca1f2bcdcde347767 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
a498a2865e
commit
6cbc99d3ee
|
@ -312,8 +312,7 @@ PackIndex writePackIndex(DfsPackDescription pack, byte[] packHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
DfsOutputStream os = db.writeFile(pack, INDEX);
|
DfsOutputStream os = db.writeFile(pack, INDEX);
|
||||||
try {
|
try (CountingOutputStream cnt = new CountingOutputStream(os)) {
|
||||||
CountingOutputStream cnt = new CountingOutputStream(os);
|
|
||||||
if (buf != null)
|
if (buf != null)
|
||||||
buf.writeTo(cnt, null);
|
buf.writeTo(cnt, null);
|
||||||
else
|
else
|
||||||
|
@ -321,7 +320,9 @@ PackIndex writePackIndex(DfsPackDescription pack, byte[] packHash,
|
||||||
pack.addFileExt(INDEX);
|
pack.addFileExt(INDEX);
|
||||||
pack.setFileSize(INDEX, cnt.getCount());
|
pack.setFileSize(INDEX, cnt.getCount());
|
||||||
} finally {
|
} finally {
|
||||||
os.close();
|
if (buf != null) {
|
||||||
|
buf.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return packIndex;
|
return packIndex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue