diff options
author | Jonathan Nieder <jrn@google.com> | 2013-05-24 18:24:53 -0700 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2013-05-24 18:28:37 -0700 |
commit | f99fa9d23e93fdd34124e2100d629680894477d7 (patch) | |
tree | baf39310ce76f7ce50939fbedc1302a63de4517e /org.eclipse.jgit.pgm/src/org/eclipse | |
parent | 56276d053f44209f25951d3acfba226c563a81f0 (diff) | |
download | jgit-f99fa9d23e93fdd34124e2100d629680894477d7.tar.gz jgit-f99fa9d23e93fdd34124e2100d629680894477d7.zip |
Release ArchiveCommand's ObjectReader in call()
Make call() release all private resources so instead of using a
pattern like
ArchiveCommand cmd = git.archive();
try {
cmd.setTree(tree)
. ...
.call();
} finally {
cmd.release();
}
callers can just use git.archive().setTree(tree)....call() directly.
This involves pushing more work out of parameter setters and into
call() so the ObjectReader is not allocated and potentially leaked
before then.
Change-Id: I699f703c6302696e1cc276d7ab8ee597d82f2c5d
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java index 0513fb2e24..9aa09b4648 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java @@ -72,15 +72,14 @@ class Archive extends TextBuiltin { if (tree == null) throw die(CLIText.get().treeIsRequired); - final ArchiveCommand cmd = new Git(db).archive(); try { - cmd.setTree(tree) - .setFormat(format) - .setOutputStream(outs).call(); + new Git(db).archive() + .setTree(tree) + .setFormat(format) + .setOutputStream(outs) + .call(); } catch (GitAPIException e) { throw die(e.getMessage()); - } finally { - cmd.release(); } } } |