Browse Source

Merge "Use try-with-resource to close resources in DiffCommand"

stable-4.1
Shawn Pearce 10 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
15a95e3911
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java

7
org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java

@ -124,11 +124,8 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
if (head == null)
throw new NoHeadException(JGitText.get().cannotReadTree);
CanonicalTreeParser p = new CanonicalTreeParser();
ObjectReader reader = repo.newObjectReader();
try {
try (ObjectReader reader = repo.newObjectReader()) {
p.reset(reader, head);
} finally {
reader.release();
}
oldTree = p;
}
@ -159,7 +156,7 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
} finally {
diffFmt.release();
diffFmt.close();
}
}

Loading…
Cancel
Save