diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2015-04-02 00:40:44 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-04-02 00:41:19 +0200 |
commit | e5b81e49e8819e023ae1ca89e9d9edb218d23371 (patch) | |
tree | d4f6230240a7fecd9341c47f77c8a87e24e6f84e | |
parent | d94ce9c754b740defbd75230663d323f64cc9648 (diff) | |
download | jgit-e5b81e49e8819e023ae1ca89e9d9edb218d23371.tar.gz jgit-e5b81e49e8819e023ae1ca89e9d9edb218d23371.zip |
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>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java index c23256c74b..de6c32a808 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java @@ -137,13 +137,12 @@ public class AddCommand extends GitCommand<DirCache> { 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 @@ public class AddCommand extends GitCommand<DirCache> { throw new JGitInternalException( JGitText.get().exceptionCaughtDuringExecutionOfAddCommand, e); } finally { - inserter.release(); if (dc != null) dc.unlock(); } |