Adapt to enabling CheckReturnValue in gerrit core
Bug: Google b/312699566
Change-Id: Ib93b816f09db5e2d6f7c4c973317a3a8b1352a8e
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java
index 1a097c1..aebbe0e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/ExportReviewNotes.java
@@ -91,27 +91,29 @@
private void export(Project.NameKey project, List<ChangeNotes> notes)
throws RestApiException, UpdateException {
- retryHelper
- .changeUpdate(
- "exportReviewNotes",
- updateFactory -> {
- try (Repository git = gitManager.openRepository(project)) {
- CreateReviewNotes crn = reviewNotesFactory.create(project, git);
- crn.createNotes(notes, monitor);
- crn.commitNotes();
- } catch (RepositoryNotFoundException e) {
- stderr.println("Unable to open project: " + project.get());
- }
- return null;
- })
- .listener(
- new RetryListener() {
- @Override
- public <V> void onRetry(Attempt<V> attempt) {
- monitor.update(-notes.size());
- }
- })
- .call();
+ @SuppressWarnings("unused")
+ var unused =
+ retryHelper
+ .changeUpdate(
+ "exportReviewNotes",
+ updateFactory -> {
+ try (Repository git = gitManager.openRepository(project)) {
+ CreateReviewNotes crn = reviewNotesFactory.create(project, git);
+ crn.createNotes(notes, monitor);
+ crn.commitNotes();
+ } catch (RepositoryNotFoundException e) {
+ stderr.println("Unable to open project: " + project.get());
+ }
+ return null;
+ })
+ .listener(
+ new RetryListener() {
+ @Override
+ public <V> void onRetry(Attempt<V> attempt) {
+ monitor.update(-notes.size());
+ }
+ })
+ .call();
}
@Nullable
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java
index 1f8826f..2b39e56 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/RefUpdateListener.java
@@ -98,23 +98,25 @@
return;
}
try {
- retryHelper
- .changeUpdate(
- "createReviewNotes",
- updateFactory -> {
- Project.NameKey projectName = Project.nameKey(e.getProjectName());
- try (Repository git = repoManager.openRepository(projectName)) {
- CreateReviewNotes crn = reviewNotesFactory.create(projectName, git);
- crn.createNotes(
- e.getRefName(),
- ObjectId.fromString(e.getOldObjectId()),
- ObjectId.fromString(e.getNewObjectId()),
- null);
- crn.commitNotes();
- }
- return null;
- })
- .call();
+ @SuppressWarnings("unused")
+ var unused =
+ retryHelper
+ .changeUpdate(
+ "createReviewNotes",
+ updateFactory -> {
+ Project.NameKey projectName = Project.nameKey(e.getProjectName());
+ try (Repository git = repoManager.openRepository(projectName)) {
+ CreateReviewNotes crn = reviewNotesFactory.create(projectName, git);
+ crn.createNotes(
+ e.getRefName(),
+ ObjectId.fromString(e.getOldObjectId()),
+ ObjectId.fromString(e.getNewObjectId()),
+ null);
+ crn.commitNotes();
+ }
+ return null;
+ })
+ .call();
} catch (RestApiException | UpdateException x) {
logger.atSevere().withCause(x).log("%s", x.getMessage());
}