Use try-with-resources to fix warnings in AddCommand
- replaces use of deprecated ObjectInserter.release() - auto-close TreeWalk Change-Id: I540ee711b8c3430a71fdff07add506b7d9c039dc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
d94ce9c754
commit
e5b81e49e8
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue