diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-12-18 01:33:58 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-12-18 13:49:33 +0100 |
commit | fbcc2cb4ca6b1732e28edeb766b8d57e2de560ce (patch) | |
tree | 3dca1e1eb2371921f01cc9fbdf7d8f529b6aafe4 | |
parent | 82344bd7a234de3cb7fd3358d2ba355adb484181 (diff) | |
download | jgit-fbcc2cb4ca6b1732e28edeb766b8d57e2de560ce.tar.gz jgit-fbcc2cb4ca6b1732e28edeb766b8d57e2de560ce.zip |
[infer] Fix resource leaks in SubmoduleAddCommand
Bug: 509385
Change-Id: I9d25cf117cfb19df108f5fe281232193fd898474
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java index fbb24c1577..b0f772e0aa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java +++ b/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(); |