From aa199ff648a3b683ce128c3293d4f529bac6864b Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 18 Dec 2016 01:37:01 +0100 Subject: [PATCH] [infer] Fix SubmoduleWalk leaks in submodule commands Bug: 509385 Change-Id: I4cba81d8ea596800a40799dc9cb763fae01fe508 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/api/SubmoduleInitCommand.java | 3 +-- .../src/org/eclipse/jgit/api/SubmoduleStatusCommand.java | 3 +-- .../src/org/eclipse/jgit/api/SubmoduleSyncCommand.java | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java index 0ed02acc8..1dbe3681b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java @@ -94,8 +94,7 @@ public class SubmoduleInitCommand extends GitCommand> { public Collection call() throws GitAPIException { checkCallable(); - try { - SubmoduleWalk generator = SubmoduleWalk.forIndex(repo); + try (SubmoduleWalk generator = SubmoduleWalk.forIndex(repo)) { if (!paths.isEmpty()) generator.setFilter(PathFilterGroup.createFromStrings(paths)); StoredConfig config = repo.getConfig(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java index 968041c3a..a1ea790d0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java @@ -94,8 +94,7 @@ public class SubmoduleStatusCommand extends public Map call() throws GitAPIException { checkCallable(); - try { - SubmoduleWalk generator = SubmoduleWalk.forIndex(repo); + try (SubmoduleWalk generator = SubmoduleWalk.forIndex(repo)) { if (!paths.isEmpty()) generator.setFilter(PathFilterGroup.createFromStrings(paths)); Map statuses = new HashMap(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java index 024f0bebd..088eedc2d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java @@ -111,8 +111,7 @@ public class SubmoduleSyncCommand extends GitCommand> { public Map call() throws GitAPIException { checkCallable(); - try { - SubmoduleWalk generator = SubmoduleWalk.forIndex(repo); + try (SubmoduleWalk generator = SubmoduleWalk.forIndex(repo)) { if (!paths.isEmpty()) generator.setFilter(PathFilterGroup.createFromStrings(paths)); Map synced = new HashMap();