Browse Source

archive: Release resources before returning

The only caller exits immediately after calling execute() so this
shouldn't make a difference, but it's good practice and should make it
easier to expose the functionality in a public API later.

Change-Id: Ia6cd2ce8382f1a62e576409107fc5c9a6b321fb6
stable-3.0
Jonathan Nieder 12 years ago
parent
commit
70e494f649
  1. 12
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java

12
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java

@ -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 @@ class Archive extends TextBuiltin {
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( //

Loading…
Cancel
Save