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); }