Browse Source

[infer] Fix resource leak in IndexDiff

We only need the tree id to add it to a TreeWalk so change tree's type
to AnyObjectId.

Bug: 509385
Change-Id: I98dd5fef15cd173fe1fd84273f0f48e64e12e608
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.6
Matthias Sohn 8 years ago
parent
commit
1fb2319c18
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java

12
org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java

@ -65,7 +65,6 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.StopWalkException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.jgit.submodule.SubmoduleWalk.IgnoreSubmoduleMode;
@ -248,7 +247,7 @@ public class IndexDiff {
private final Repository repository;
private final RevTree tree;
private final AnyObjectId tree;
private TreeFilter filter = null;
@ -311,10 +310,13 @@ public class IndexDiff {
public IndexDiff(Repository repository, ObjectId objectId,
WorkingTreeIterator workingTreeIterator) throws IOException {
this.repository = repository;
if (objectId != null)
tree = new RevWalk(repository).parseTree(objectId);
else
if (objectId != null) {
try (RevWalk rw = new RevWalk(repository)) {
tree = rw.parseTree(objectId);
}
} else {
tree = null;
}
this.initialWorkingTreeIterator = workingTreeIterator;
}

Loading…
Cancel
Save