From b88f3a2a2c598958865027c1d2d0adbf89a2db69 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Mon, 24 Nov 2014 11:51:32 -0800 Subject: [PATCH] Cleanup TreeWalk creation/release inside StashApplyCommand The TreeWalk constructor doesn't throw in a meaninful way that requires cleanup of the not-yet-created TreeWalk. Hoist the constructor outside of the try/finally and remove the now unnecessary != null check during the finally. Change-Id: If5b8bb91562715df0699726648123a47426b9850 --- .../src/org/eclipse/jgit/api/StashApplyCommand.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java index 4d54e0be9..5d0ac2f2d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java @@ -329,9 +329,8 @@ public class StashApplyCommand extends GitCommand { private void resetUntracked(RevTree tree) throws CheckoutConflictException, IOException { - TreeWalk walk = null; + TreeWalk walk = new TreeWalk(repo); // maybe NameConflictTreeWalk; try { - walk = new TreeWalk(repo); // maybe NameConflictTreeWalk? walk.addTree(tree); walk.addTree(new FileTreeIterator(repo)); walk.setRecursive(true); @@ -362,8 +361,7 @@ public class StashApplyCommand extends GitCommand { checkoutPath(entry, reader); } } finally { - if (walk != null) - walk.release(); + walk.release(); } }