Merge "archive: Release resources before returning"

This commit is contained in:
Shawn Pearce 2013-04-26 16:06:25 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 543b8560ac
1 changed files with 21 additions and 17 deletions

View File

@ -78,15 +78,17 @@ class Archive extends TextBuiltin {
@Override
protected void run() throws Exception {
final TreeWalk walk = new TreeWalk(db);
final ObjectReader reader = walk.getObjectReader();
final MutableObjectId idBuf = new MutableObjectId();
final Archiver fmt = formats.get(format);
final ArchiveOutputStream outa = fmt.createArchiveOutputStream(outs);
if (tree == null)
throw die(CLIText.get().treeIsRequired);
final ArchiveOutputStream outa = fmt.createArchiveOutputStream(outs);
final TreeWalk walk = new TreeWalk(db);
final ObjectReader reader = walk.getObjectReader();
try {
walk.reset();
walk.addTree(tree);
walk.setRecursive(true);
@ -102,9 +104,11 @@ protected void run() throws Exception {
walk.getObjectId(idBuf, 0);
fmt.putEntry(name, mode, reader.open(idBuf), outa);
}
} finally {
reader.release();
outa.close();
}
}
static private void warnArchiveEntryModeIgnored(String name) {
System.err.println(MessageFormat.format( //