Use try-with-resource to close resources in CherryPickCommand
Change-Id: I62d6de7d67c7de2460f4cbe918ad2bb8109650b9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
81c84c088f
commit
58c2c52219
|
@ -123,8 +123,7 @@ public CherryPickResult call() throws GitAPIException, NoMessageException,
|
||||||
List<Ref> cherryPickedRefs = new LinkedList<Ref>();
|
List<Ref> cherryPickedRefs = new LinkedList<Ref>();
|
||||||
checkCallable();
|
checkCallable();
|
||||||
|
|
||||||
RevWalk revWalk = new RevWalk(repo);
|
try (RevWalk revWalk = new RevWalk(repo)) {
|
||||||
try {
|
|
||||||
|
|
||||||
// get the head commit
|
// get the head commit
|
||||||
Ref headRef = repo.getRef(Constants.HEAD);
|
Ref headRef = repo.getRef(Constants.HEAD);
|
||||||
|
@ -194,8 +193,6 @@ public CherryPickResult call() throws GitAPIException, NoMessageException,
|
||||||
MessageFormat.format(
|
MessageFormat.format(
|
||||||
JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
|
JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand,
|
||||||
e), e);
|
e), e);
|
||||||
} finally {
|
|
||||||
revWalk.release();
|
|
||||||
}
|
}
|
||||||
return new CherryPickResult(newHead, cherryPickedRefs);
|
return new CherryPickResult(newHead, cherryPickedRefs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue