diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java index 87086cbde..fbdffbc48 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java @@ -542,10 +542,9 @@ public boolean diff(final ProgressMonitor monitor, int estWorkTreeSize, JGitText.get().invalidIgnoreParamSubmodule, smw.getPath()), e); } - Repository subRepo = smw.getRepository(); - if (subRepo != null) { - String subRepoPath = smw.getPath(); - try { + try (Repository subRepo = smw.getRepository()) { + if (subRepo != null) { + String subRepoPath = smw.getPath(); ObjectId subHead = subRepo.resolve("HEAD"); //$NON-NLS-1$ if (subHead != null && !subHead.equals(smw.getObjectId())) { @@ -574,8 +573,6 @@ public boolean diff(final ProgressMonitor monitor, int estWorkTreeSize, recordFileMode(subRepoPath, FileMode.GITLINK); } } - } finally { - subRepo.close(); } } }