diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java index 1aab51e9c..b71e9902c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java @@ -173,7 +173,7 @@ public class DiffFormatter implements AutoCloseable { */ public void setRepository(Repository repository) { if (reader != null) - reader.release(); + reader.close(); db = repository; reader = db.newObjectReader(); @@ -422,10 +422,11 @@ public class DiffFormatter implements AutoCloseable { throws IOException { assertHaveRepository(); - RevWalk rw = new RevWalk(reader); - RevTree aTree = a != null ? rw.parseTree(a) : null; - RevTree bTree = b != null ? rw.parseTree(b) : null; - return scan(aTree, bTree); + try (RevWalk rw = new RevWalk(reader)) { + RevTree aTree = a != null ? rw.parseTree(a) : null; + RevTree bTree = b != null ? rw.parseTree(b) : null; + return scan(aTree, bTree); + } } /**