Skip to main content
diff options
authorChristian Halstrick2012-06-15 22:19:51 +0000
committerMatthias Sohn2012-06-15 22:19:51 +0000
commit80113c7bb65c4c624250e430b5f2b19b1367d18c (patch)
treee3bc527bf93014d3d4f577c60bd6a7e559374012 /org.eclipse.jgit.ant
parentc745c93e40abdad7afde4e3b48dbb11469916112 (diff)
Fix resource leaks due to unclosed repositories
Whenever a call to JGit returns a Repository the caller should make sure to call close() on it if he doesn't need it anymore. Since instances of Repository contain e.g. open FileOutputStreams (for pack files) forgetting to close the repository can lead to resource leaks. This was the reason why dozens of the JUnit tests failed on Windows with "Can't delete file ...." errors. In LocalDiskRepositoryTestCase.tearDown() we tried to delete the repositories we used during tests which failed because we had open FileOutputStreams. Not only the obvious cases during Clone or Init operations returned Repositories, but also the new SubModule API created repository instances. In some places we even forgot to close submodule repositories in our internal coding. To see the effects of this fix run the JGit JUnit tests under Windows. On other platforms it's harder to see because either the leaking resources don't lead to failing JUnit tests (on Unix you can delete files with open FileOutputStreams) or the java gc runs differently and cleans up the resources earlier. Change-Id: I6d4f637b0d4af20ff4d501db091548696373a58a Signed-off-by: Christian Halstrick <> Signed-off-by: Matthias Sohn <>
Diffstat (limited to 'org.eclipse.jgit.ant')
1 files changed, 1 insertions, 1 deletions
diff --git a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/ b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/
index 8d12ce3ad4..f23f3b753d 100644
--- a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/
+++ b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/
@@ -109,7 +109,7 @@ public class GitCloneTask extends Task {
CloneCommand clone = Git.cloneRepository();
try {
} catch (Exception e) {
log("Could not clone repository: " + e, e, Project.MSG_ERR);
throw new BuildException("Could not clone repository: " + e.getMessage(), e);

Back to the top