From 3206f37cc3b9e500bd531e72310b7a3987114d6e Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 2 Apr 2015 00:46:59 +0200 Subject: [PATCH 1/2] Use try-with-resources to fix warnings in AddNoteCommand Replaces use of deprecated release() methods. Change-Id: I0211bcf0a76a2fccc2c85fa74778e20c256984ba Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/api/AddNoteCommand.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java index 3af86959d..f4ff5ce04 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java @@ -83,11 +83,10 @@ protected AddNoteCommand(Repository repo) { public Note call() throws GitAPIException { checkCallable(); - RevWalk walk = new RevWalk(repo); - ObjectInserter inserter = repo.newObjectInserter(); NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; - try { + try (RevWalk walk = new RevWalk(repo); + ObjectInserter inserter = repo.newObjectInserter()) { Ref ref = repo.getRef(notesRef); // if we have a notes ref, use it if (ref != null) { @@ -100,9 +99,6 @@ public Note call() throws GitAPIException { return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); - } finally { - inserter.release(); - walk.release(); } } From 114dee677076e842a5af12e9fb197d6199f5d53f Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 2 Apr 2015 00:51:02 +0200 Subject: [PATCH 2/2] Silence warning for non-translatable String in AddNoteCommand Change-Id: Iad4d41271eff4e8744efece5bc777c1cb06dead7 Signed-off-by: Matthias Sohn --- org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java index f4ff5ce04..9cf888195 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java @@ -95,7 +95,7 @@ public Note call() throws GitAPIException { } map.set(id, message, inserter); commitNoteMap(walk, map, notesCommit, inserter, - "Notes added by 'git notes add'"); + "Notes added by 'git notes add'"); //$NON-NLS-1$ return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e);