diff options
author | James Moger <james.moger@gitblit.com> | 2014-02-28 14:28:58 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-03-01 09:21:19 -0500 |
commit | 115551c76c3af879b49447dce64d7a6c29049c40 (patch) | |
tree | 50b9f4da869b6b0c323764616123531e35eda7c4 /src | |
parent | 835529db4edb7b3c5c67e58b3dd1080e8772a642 (diff) | |
download | gitblit-115551c76c3af879b49447dce64d7a6c29049c40.tar.gz gitblit-115551c76c3af879b49447dce64d7a6c29049c40.zip |
Properly dispose RevWalk in getCommit
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/utils/JGitUtils.java | 11 |
1 files 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;
}
|