Browse Source

Use try-with-resource to close resources in CherryPickCommand

Change-Id: I62d6de7d67c7de2460f4cbe918ad2bb8109650b9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.1
Matthias Sohn 10 years ago
parent
commit
58c2c52219
  1. 5
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

5
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

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

Loading…
Cancel
Save