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,
|
private DfsPackDescription writePack(PackSource source, PackWriter pw,
|
||||||
ProgressMonitor pm) throws IOException {
|
ProgressMonitor pm) throws IOException {
|
||||||
DfsOutputStream out;
|
|
||||||
DfsPackDescription pack = repo.getObjectDatabase().newPack(source);
|
DfsPackDescription pack = repo.getObjectDatabase().newPack(source);
|
||||||
newPackDesc.add(pack);
|
newPackDesc.add(pack);
|
||||||
|
|
||||||
out = objdb.writeFile(pack, PACK);
|
try (DfsOutputStream out = objdb.writeFile(pack, PACK)) {
|
||||||
try {
|
|
||||||
pw.writePack(pm, pm, out);
|
pw.writePack(pm, pm, out);
|
||||||
pack.addFileExt(PACK);
|
pack.addFileExt(PACK);
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out = objdb.writeFile(pack, INDEX);
|
try (DfsOutputStream out = objdb.writeFile(pack, INDEX);
|
||||||
try {
|
CountingOutputStream cnt = new CountingOutputStream(out)) {
|
||||||
CountingOutputStream cnt = new CountingOutputStream(out);
|
|
||||||
pw.writeIndex(cnt);
|
pw.writeIndex(cnt);
|
||||||
pack.addFileExt(INDEX);
|
pack.addFileExt(INDEX);
|
||||||
pack.setFileSize(INDEX, cnt.getCount());
|
pack.setFileSize(INDEX, cnt.getCount());
|
||||||
pack.setIndexVersion(pw.getIndexVersion());
|
pack.setIndexVersion(pw.getIndexVersion());
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pw.prepareBitmapIndex(pm)) {
|
if (pw.prepareBitmapIndex(pm)) {
|
||||||
out = objdb.writeFile(pack, BITMAP_INDEX);
|
try (DfsOutputStream out = objdb.writeFile(pack, BITMAP_INDEX);
|
||||||
try {
|
CountingOutputStream cnt = new CountingOutputStream(out)) {
|
||||||
CountingOutputStream cnt = new CountingOutputStream(out);
|
|
||||||
pw.writeBitmapIndex(cnt);
|
pw.writeBitmapIndex(cnt);
|
||||||
pack.addFileExt(BITMAP_INDEX);
|
pack.addFileExt(BITMAP_INDEX);
|
||||||
pack.setFileSize(BITMAP_INDEX, cnt.getCount());
|
pack.setFileSize(BITMAP_INDEX, cnt.getCount());
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue