From c6a2c58624e4fe4625a0e651f4e0eb91f019b381 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 14 Mar 2018 13:39:23 +0900 Subject: [PATCH] SubmoduleStatusCommand: Open Repository in try-with-resource Change-Id: Id65c8a94d43bc01e76733eb2ff87635d0f8a8dc2 Signed-off-by: David Pursehouse --- .../eclipse/jgit/api/SubmoduleStatusCommand.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 -- 2.39.5