Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] InitCommand Repository Left Open?

Hi,

I wanted to confirm if this is an issue or not before filing a bug.

I happened to be looking over my own code as I noticed resources weren't being freed and I kept seeing memory increase every run through.

During this look over, I happened to look at jgit's code a little and saw this.
https://github.com/eclipse/jgit/blob/master/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java#L120-L123
Repository repository = builder.build();
if (!repository.getObjectDatabase().exists())
    repository.create(bare);
return new Git(repository);

The only thing returned from this method is the `Git` object, and by default, `Git` will not close the repository given to it when it is closed. So if I call `close` on `Git`, that repository will remain open in the background, right?
Shouldn't this method be returning `new Git(repository, true)` to ensure that the repository is closed when `Git` is closed?
Obviously, you can get the repository manually from the Git and close it by hand, but it is not obvious without looking at the source that you have to do this process manually.

Back to the top