diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-14 12:10:50 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-15 07:57:02 +0900 |
commit | 5639639b06c004d18415f59a271319da2fb7b930 (patch) | |
tree | 6d2fc0b3ccf92c8e2b4d581e2f4648fab8d4829c | |
parent | 7bd2a4a7c60d183b26b59995063a38f5573112ec (diff) | |
download | jgit-5639639b06c004d18415f59a271319da2fb7b930.tar.gz jgit-5639639b06c004d18415f59a271319da2fb7b930.zip |
IndexDiff: Refactor to open Repository in try-with-resource
Change-Id: I667d685ccedc730e786f1e52323fdeba4b91af3e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java | 9 |
1 files changed, 3 insertions, 6 deletions
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 87086cbde0..fbdffbc48e 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 class IndexDiff { 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 class IndexDiff { recordFileMode(subRepoPath, FileMode.GITLINK); } } - } finally { - subRepo.close(); } } } |