Browse Source

Fix resource leak in DiffFormatter

- close RevWalk allocated in scan()
- replace use of deprecated ObjectReader.release() method

Change-Id: I41b2b10a1a44270a6ceaa1741e996c0921439852
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.1
Matthias Sohn 10 years ago
parent
commit
ff0a7b719e
  1. 11
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java

11
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);
}
}
/**

Loading…
Cancel
Save