Skip to content

Commit 914dd6f

Browse files
committed
Properly close JGit repository
1 parent 8ad0ba8 commit 914dd6f

File tree

1 file changed

+5
-1
lines changed
  • maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info

1 file changed

+5
-1
lines changed

maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public class JGitInfoCommand extends AbstractCommand implements GitCommand {
5454
protected ScmResult executeCommand(
5555
ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
5656
File basedir = fileSet.getBasedir();
57-
try (Git git = JGitUtils.openRepo(basedir); ) {
57+
Git git = null;
58+
try {
59+
git = JGitUtils.openRepo(basedir);
5860
ObjectId objectId = git.getRepository().resolve(Constants.HEAD);
5961
if (objectId == null) {
6062
throw new ScmException("Cannot resolve HEAD in git repository at " + basedir);
@@ -74,6 +76,8 @@ protected ScmResult executeCommand(
7476
return new InfoScmResult(infoItems, new ScmResult("JGit.resolve(HEAD)", "", objectId.toString(), true));
7577
} catch (Exception e) {
7678
throw new ScmException("JGit resolve failure!", e);
79+
} finally {
80+
JGitUtils.closeRepo(git);
7781
}
7882
}
7983

0 commit comments

Comments
 (0)