From: James Moger Date: Fri, 28 Feb 2014 19:28:58 +0000 (-0500) Subject: Properly dispose RevWalk in getCommit X-Git-Tag: v1.4.0~86 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=115551c76c3af879b49447dce64d7a6c29049c40;p=gitblit.git Properly dispose RevWalk in getCommit --- diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index 212a90af..7621c0e0 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -704,6 +704,7 @@ public class JGitUtils { return null; } RevCommit commit = null; + RevWalk walk = null; try { // resolve object id ObjectId branchObject; @@ -712,12 +713,18 @@ public class JGitUtils { } else { branchObject = repository.resolve(objectId); } - RevWalk walk = new RevWalk(repository); + if (branchObject == null) { + return null; + } + walk = new RevWalk(repository); RevCommit rev = walk.parseCommit(branchObject); commit = rev; - walk.dispose(); } catch (Throwable t) { error(t, repository, "{0} failed to get commit {1}", objectId); + } finally { + if (walk != null) { + walk.dispose(); + } } return commit; }