return null;\r
}\r
RevCommit commit = null;\r
+ RevWalk walk = null;\r
try {\r
// resolve object id\r
ObjectId branchObject;\r
} else {\r
branchObject = repository.resolve(objectId);\r
}\r
- RevWalk walk = new RevWalk(repository);\r
+ if (branchObject == null) {\r
+ return null;\r
+ }\r
+ walk = new RevWalk(repository);\r
RevCommit rev = walk.parseCommit(branchObject);\r
commit = rev;\r
- walk.dispose();\r
} catch (Throwable t) {\r
error(t, repository, "{0} failed to get commit {1}", objectId);\r
+ } finally {\r
+ if (walk != null) {\r
+ walk.dispose();\r
+ }\r
}\r
return commit;\r
}\r