Adapt injection of UrlFormatter to DynamicItem
Since I375245647 the UrlFormatter is not bound anymore
directly but through a DynamicItem.
Bug: Issue 10131
Change-Id: I3da6397bab34569029db4e3d6fd9b80a7197381b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
index 43dd34f..d2a8c1d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/reviewnotes/CreateReviewNotes.java
@@ -17,6 +17,7 @@
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes;
+import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
@@ -74,7 +75,7 @@
private final ChangeNotes.Factory notesFactory;
private final NotesBranchUtil.Factory notesBranchUtilFactory;
private final Provider<InternalChangeQuery> queryProvider;
- private final UrlFormatter urlFormatter;
+ private final DynamicItem<UrlFormatter> urlFormatter;
private final ReviewDb reviewDb;
private final Project.NameKey project;
private final Repository git;
@@ -93,7 +94,7 @@
ChangeNotes.Factory notesFactory,
NotesBranchUtil.Factory notesBranchUtilFactory,
Provider<InternalChangeQuery> queryProvider,
- UrlFormatter urlFormatter,
+ DynamicItem<UrlFormatter> urlFormatter,
@Assisted ReviewDb reviewDb,
@Assisted Project.NameKey project,
@Assisted Repository git) {
@@ -280,8 +281,9 @@
fmt.appendSubmittedAt(submit.getGranted());
}
- if (urlFormatter.getWebUrl().isPresent()) {
- fmt.appendReviewedOn(urlFormatter, notes.getChange().getProject(), ps.getId().getParentKey());
+ UrlFormatter uf = urlFormatter.get();
+ if (uf != null && uf.getWebUrl().isPresent()) {
+ fmt.appendReviewedOn(uf, notes.getChange().getProject(), ps.getId().getParentKey());
}
fmt.appendProject(project.get());
fmt.appendBranch(change.getDest().get());