Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2015-05-20 23:45:20 +0000
committerMatthias Sohn2015-05-21 08:22:35 +0000
commitae24740051491a4aa5d02ef4f94ca8d3399d90f2 (patch)
treea5371f29cc7fa8b0e714cbf6f773addb365eb011 /org.eclipse.egit.mylyn.ui/src/org
parent8b8c71f2cfbe2a44aa4e617d7b1ded714905aab3 (diff)
downloadegit-ae24740051491a4aa5d02ef4f94ca8d3399d90f2.tar.gz
egit-ae24740051491a4aa5d02ef4f94ca8d3399d90f2.tar.xz
egit-ae24740051491a4aa5d02ef4f94ca8d3399d90f2.zip
Use try-with-resource to avoid leaks with RevWalk and TreeWalk
Change-Id: I1ea48039ea38766bb07f079e5ef4569de034d577 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.mylyn.ui/src/org')
-rw-r--r--org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
index f201fdab91..dafc8967be 100644
--- a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
+++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
@@ -79,14 +79,13 @@ public class TaskReferenceFactory implements IAdapterFactory {
private AbstractTaskReference adaptFromRevCommit(RevCommit commit) {
Repository[] repositories = Activator.getDefault().getRepositoryCache().getAllRepositories();
for (Repository r : repositories) {
- RevWalk revWalk = new RevWalk(r);
String repoUrl = null;
String message = null;
long timestamp = 0;
// try to get repository url and commit message
- try {
+ try (RevWalk revWalk = new RevWalk(r)) {
RevCommit revCommit = revWalk.parseCommit(commit);
if (revCommit != null) {
repoUrl = getRepoUrl(r);
@@ -127,8 +126,9 @@ public class TaskReferenceFactory implements IAdapterFactory {
GitModelRepository parent = (GitModelRepository) modelCommit.getParent();
Repository repo = parent.getRepository();
AbbreviatedObjectId id = modelCommit.getCachedCommitObj().getId();
-
- commit = new RevWalk(repo).lookupCommit(id.toObjectId());
+ try (RevWalk rw = new RevWalk(repo)) {
+ commit = rw.lookupCommit(id.toObjectId());
+ }
}
return commit;
}

Back to the top