Browse Source

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 <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago committed by Matthias Sohn
parent
commit
b3a4ace695
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

4
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

@ -191,12 +191,12 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
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) {

Loading…
Cancel
Save