From b3a4ace695328945fcebb85be102733c97c498ac Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 20 Mar 2018 11:28:18 +0900 Subject: [PATCH] CloneCommand: Suppress resource warning about Repository Repository is not opened in try-with-resource because it is wrapped in a Git instance which should be closed by the caller. On exeptions during fetch, it is explicitly closed in the catch blocks. Suppress the warning with an explanatory comment. Change-Id: Ib32c74ce39bb810077ab84db33002bdde806f3b6 Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java index f368e836ae..6084375e37 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java @@ -191,12 +191,12 @@ public class CloneCommand extends TransportCommand { throw new InvalidRemoteException( MessageFormat.format(JGitText.get().invalidURL, uri)); } - Repository repository = null; + @SuppressWarnings("resource") // Closed by caller + Repository repository = init(); FetchResult fetchResult = null; Thread cleanupHook = new Thread(() -> cleanup()); Runtime.getRuntime().addShutdownHook(cleanupHook); try { - repository = init(); fetchResult = fetch(repository, u); } catch (IOException ioe) { if (repository != null) { -- 2.39.5