[infer] Fix SubmoduleWalk leaks in submodule commands

Bug: 509385
Change-Id: I4cba81d8ea596800a40799dc9cb763fae01fe508
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2016-12-18 01:37:01 +01:00
parent fbcc2cb4ca
commit aa199ff648
3 changed files with 3 additions and 6 deletions

View File

@ -94,8 +94,7 @@ public SubmoduleInitCommand addPath(final String path) {
public Collection<String> call() throws GitAPIException { public Collection<String> call() throws GitAPIException {
checkCallable(); checkCallable();
try { try (SubmoduleWalk generator = SubmoduleWalk.forIndex(repo)) {
SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
if (!paths.isEmpty()) if (!paths.isEmpty())
generator.setFilter(PathFilterGroup.createFromStrings(paths)); generator.setFilter(PathFilterGroup.createFromStrings(paths));
StoredConfig config = repo.getConfig(); StoredConfig config = repo.getConfig();

View File

@ -94,8 +94,7 @@ public SubmoduleStatusCommand addPath(final String path) {
public Map<String, SubmoduleStatus> call() throws GitAPIException { public Map<String, SubmoduleStatus> call() throws GitAPIException {
checkCallable(); checkCallable();
try { try (SubmoduleWalk generator = SubmoduleWalk.forIndex(repo)) {
SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
if (!paths.isEmpty()) if (!paths.isEmpty())
generator.setFilter(PathFilterGroup.createFromStrings(paths)); generator.setFilter(PathFilterGroup.createFromStrings(paths));
Map<String, SubmoduleStatus> statuses = new HashMap<String, SubmoduleStatus>(); Map<String, SubmoduleStatus> statuses = new HashMap<String, SubmoduleStatus>();

View File

@ -111,8 +111,7 @@ protected String getHeadBranch(final Repository subRepo) throws IOException {
public Map<String, String> call() throws GitAPIException { public Map<String, String> call() throws GitAPIException {
checkCallable(); checkCallable();
try { try (SubmoduleWalk generator = SubmoduleWalk.forIndex(repo)) {
SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
if (!paths.isEmpty()) if (!paths.isEmpty())
generator.setFilter(PathFilterGroup.createFromStrings(paths)); generator.setFilter(PathFilterGroup.createFromStrings(paths));
Map<String, String> synced = new HashMap<String, String>(); Map<String, String> synced = new HashMap<String, String>();