From 58c2c52219af57d47bade73a0e7f2a6d4713ea9d Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 3 Apr 2015 00:32:08 +0200 Subject: [PATCH] Use try-with-resource to close resources in CherryPickCommand Change-Id: I62d6de7d67c7de2460f4cbe918ad2bb8109650b9 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/api/CherryPickCommand.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java index d4eb0b3b2..0a6875dbc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java @@ -123,8 +123,7 @@ public CherryPickResult call() throws GitAPIException, NoMessageException, List cherryPickedRefs = new LinkedList(); checkCallable(); - RevWalk revWalk = new RevWalk(repo); - try { + try (RevWalk revWalk = new RevWalk(repo)) { // get the head commit Ref headRef = repo.getRef(Constants.HEAD); @@ -194,8 +193,6 @@ public CherryPickResult call() throws GitAPIException, NoMessageException, MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand, e), e); - } finally { - revWalk.release(); } return new CherryPickResult(newHead, cherryPickedRefs); }