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

This commit is contained in:
Shawn Pearce 2015-04-08 15:26:06 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 15a95e3911
1 changed files with 2 additions and 5 deletions

View File

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