From: David Pursehouse Date: Wed, 14 Mar 2018 04:39:23 +0000 (+0900) Subject: SubmoduleStatusCommand: Open Repository in try-with-resource X-Git-Tag: v5.0.0.201805151920-m7~69 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F119387%2F4;p=jgit.git SubmoduleStatusCommand: Open Repository in try-with-resource Change-Id: Id65c8a94d43bc01e76733eb2ff87635d0f8a8dc2 Signed-off-by: David Pursehouse --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java index 97ae668078..5c21864202 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java @@ -130,16 +130,14 @@ public class SubmoduleStatusCommand extends id); // Report uninitialized if no submodule repository - Repository subRepo = generator.getRepository(); - if (subRepo == null) - return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED, path, - id); + ObjectId headId = null; + try (Repository subRepo = generator.getRepository()) { + if (subRepo == null) { + return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED, + path, id); + } - ObjectId headId; - try { headId = subRepo.resolve(Constants.HEAD); - } finally { - subRepo.close(); } // Report uninitialized if no HEAD commit in submodule repository