]> source.dussan.org Git - jgit.git/commitdiff
Use try-with-resource to close resources in CherryPickCommand 84/45184/1
authorMatthias Sohn <matthias.sohn@sap.com>
Thu, 2 Apr 2015 22:32:08 +0000 (00:32 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 2 Apr 2015 22:32:08 +0000 (00:32 +0200)
Change-Id: I62d6de7d67c7de2460f4cbe918ad2bb8109650b9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

index d4eb0b3b21ca2e9b29bbfd3f2850738301c9da7b..0a6875dbc2df9a6fd7a75213fb4ba8c599e8608b 100644 (file)
@@ -123,8 +123,7 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
                List<Ref> cherryPickedRefs = new LinkedList<Ref>();
                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 class CherryPickCommand extends GitCommand<CherryPickResult> {
                                        MessageFormat.format(
                                                        JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
                                                        e), e);
-               } finally {
-                       revWalk.release();
                }
                return new CherryPickResult(newHead, cherryPickedRefs);
        }