Merge "Use try-with-resources to fix warnings in AddCommand"

This commit is contained in:
Shawn Pearce 2015-04-08 21:08:00 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit e0d95ab577
1 changed files with 2 additions and 4 deletions

View File

@ -137,13 +137,12 @@ public DirCache call() throws GitAPIException, NoFilepatternException {
if (filepatterns.contains(".")) //$NON-NLS-1$
addAll = true;
ObjectInserter inserter = repo.newObjectInserter();
try {
try (ObjectInserter inserter = repo.newObjectInserter();
final TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheIterator c;
DirCacheBuilder builder = dc.builder();
final TreeWalk tw = new TreeWalk(repo);
tw.addTree(new DirCacheBuildIterator(builder));
if (workingTreeIterator == null)
workingTreeIterator = new FileTreeIterator(repo);
@ -212,7 +211,6 @@ else if (!(path.equals(lastAddedFile))) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfAddCommand, e);
} finally {
inserter.release();
if (dc != null)
dc.unlock();
}