From 115551c76c3af879b49447dce64d7a6c29049c40 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 28 Feb 2014 14:28:58 -0500 Subject: [PATCH] Properly dispose RevWalk in getCommit --- src/main/java/com/gitblit/utils/JGitUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; } -- 2.39.5