MergeCommand: Open RevWalk in try-with-resource Change-Id: I45ce481cc198b8dc78e9c46b433504840597e982 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index 2eced1e..cd50cae 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
@@ -237,9 +237,8 @@ public MergeResult call() throws GitAPIException, NoHeadException, fallBackToConfiguration(); checkParameters(); - RevWalk revWalk = null; DirCacheCheckout dco = null; - try { + try (RevWalk revWalk = new RevWalk(repo)) { Ref head = repo.exactRef(Constants.HEAD); if (head == null) throw new NoHeadException( @@ -247,7 +246,6 @@ public MergeResult call() throws GitAPIException, NoHeadException, StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$ // Check for FAST_FORWARD, ALREADY_UP_TO_DATE - revWalk = new RevWalk(repo); // we know for now there is only one commit Ref ref = commits.get(0); @@ -439,9 +437,6 @@ public MergeResult call() throws GitAPIException, NoHeadException, MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand, e), e); - } finally { - if (revWalk != null) - revWalk.close(); } }