Browse Source

[infer] Fix resource leaks in SubmoduleAddCommand

Bug: 509385
Change-Id: I9d25cf117cfb19df108f5fe281232193fd898474
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.6
Matthias Sohn 8 years ago
parent
commit
fbcc2cb4ca
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java

10
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java

@ -133,7 +133,9 @@ public class SubmoduleAddCommand extends
*/
protected boolean submoduleExists() throws IOException {
TreeFilter filter = PathFilter.create(path);
return SubmoduleWalk.forIndex(repo).setFilter(filter).next();
try (SubmoduleWalk w = SubmoduleWalk.forIndex(repo)) {
return w.setFilter(filter).next();
}
}
/**
@ -178,7 +180,11 @@ public class SubmoduleAddCommand extends
clone.setURI(resolvedUri);
if (monitor != null)
clone.setProgressMonitor(monitor);
Repository subRepo = clone.call().getRepository();
Repository subRepo = null;
try (Git git = clone.call()) {
subRepo = git.getRepository();
subRepo.incrementOpen();
}
// Save submodule URL to parent repository's config
StoredConfig config = repo.getConfig();

Loading…
Cancel
Save