Use try-with-resources in DfsGarbageCollector.writePack
Change-Id: I9a73125581b4d760b733fd045c3436c2aaaab730
This commit is contained in:
parent
d8603446a2
commit
a1ca13e09c
|
@ -386,38 +386,28 @@ private PackWriter newPackWriter() {
|
|||
|
||||
private DfsPackDescription writePack(PackSource source, PackWriter pw,
|
||||
ProgressMonitor pm) throws IOException {
|
||||
DfsOutputStream out;
|
||||
DfsPackDescription pack = repo.getObjectDatabase().newPack(source);
|
||||
newPackDesc.add(pack);
|
||||
|
||||
out = objdb.writeFile(pack, PACK);
|
||||
try {
|
||||
try (DfsOutputStream out = objdb.writeFile(pack, PACK)) {
|
||||
pw.writePack(pm, pm, out);
|
||||
pack.addFileExt(PACK);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
out = objdb.writeFile(pack, INDEX);
|
||||
try {
|
||||
CountingOutputStream cnt = new CountingOutputStream(out);
|
||||
try (DfsOutputStream out = objdb.writeFile(pack, INDEX);
|
||||
CountingOutputStream cnt = new CountingOutputStream(out)) {
|
||||
pw.writeIndex(cnt);
|
||||
pack.addFileExt(INDEX);
|
||||
pack.setFileSize(INDEX, cnt.getCount());
|
||||
pack.setIndexVersion(pw.getIndexVersion());
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
if (pw.prepareBitmapIndex(pm)) {
|
||||
out = objdb.writeFile(pack, BITMAP_INDEX);
|
||||
try {
|
||||
CountingOutputStream cnt = new CountingOutputStream(out);
|
||||
try (DfsOutputStream out = objdb.writeFile(pack, BITMAP_INDEX);
|
||||
CountingOutputStream cnt = new CountingOutputStream(out)) {
|
||||
pw.writeBitmapIndex(cnt);
|
||||
pack.addFileExt(BITMAP_INDEX);
|
||||
pack.setFileSize(BITMAP_INDEX, cnt.getCount());
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue