summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org/eclipse/jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-11-20 21:21:26 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2022-11-21 00:08:42 +0100
commit4ddc64a2ddaccb1304f52b07470c7d04fce85bd7 (patch)
treefc92689c99aac29c3c81522deba2a6bb6f850aed /org.eclipse.jgit.pgm/src/org/eclipse/jgit
parent3e728166296c08079b3b4b159c4b9fd3f07687e0 (diff)
downloadjgit-4ddc64a2ddaccb1304f52b07470c7d04fce85bd7.tar.gz
jgit-4ddc64a2ddaccb1304f52b07470c7d04fce85bd7.zip
[pgm] Ensure UploadPack is closed to fix resource leak
Change-Id: I40da4b331012dd1c6f4b497e46c973fd776b737f
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
index 36103f2e6f..ac51643b6e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
@@ -42,12 +42,13 @@ class UploadPack extends TextBuiltin {
try {
FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
db = key.open(true /* must exist */);
- org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
- db);
- if (0 <= timeout) {
- up.setTimeout(timeout);
+ try (org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
+ db)) {
+ if (0 <= timeout) {
+ up.setTimeout(timeout);
+ }
+ up.upload(ins, outs, errs);
}
- up.upload(ins, outs, errs);
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
srcGitdir.getPath()), notFound);