[pgm] Ensure UploadPack is closed to fix resource leak

Change-Id: I40da4b331012dd1c6f4b497e46c973fd776b737f
This commit is contained in:
Matthias Sohn 2022-11-20 21:21:26 +01:00
parent 3e72816629
commit 4ddc64a2dd
1 changed files with 6 additions and 5 deletions

View File

@ -42,12 +42,13 @@ protected void run() {
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);