]> source.dussan.org Git - jgit.git/commitdiff
IndexDiff: Refactor to open Repository in try-with-resource 79/119379/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 03:10:50 +0000 (12:10 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 22:57:02 +0000 (07:57 +0900)
Change-Id: I667d685ccedc730e786f1e52323fdeba4b91af3e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java

index 87086cbde0590f1afb9033ab73a0c898828db689..fbdffbc48ea46afb3cdb68184f4c5946250ac1a4 100644 (file)
@@ -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();
                                        }
                                }
                        }