From a32e443e7591c4c27de48bbe722f60b190e76606 Mon Sep 17 00:00:00 2001 From: Marat Radchenko Date: Mon, 16 Dec 2019 20:49:46 +0300 Subject: [PATCH] Fix repository leak in AbstractGitSCMSource.retrieve This bug is detected by AbstractGitSCMSourceTest.when_commits_added_during_discovery_we_do_not_crash to if run against newer JTH. --- src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java b/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java index ee2890dcf7..0824ee4f9f 100644 --- a/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java +++ b/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java @@ -573,8 +573,8 @@ public Void run(GitClient client, String remoteName, FetchCommand fetch) throws remoteReferences = Collections.emptyMap(); } fetch.execute(); - final Repository repository = client.getRepository(); - try (RevWalk walk = new RevWalk(repository); + try (Repository repository = client.getRepository(); + RevWalk walk = new RevWalk(repository); GitSCMSourceRequest request = context.newRequest(AbstractGitSCMSource.this, listener)) { if (context.wantBranches()) {