Browse Source
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 <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>stable-2.1
Christian Halstrick
13 years ago
committed by
Matthias Sohn
13 changed files with 129 additions and 64 deletions
Loading…
Reference in new issue