Merge branch 'stable-2.16'
* stable-2.16:
Adapt injection of UrlFormatter to DynamicItem
Change-Id: Iabe82a50f4d4207676b1f0235b0f383374bda932
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 7f5317b..0a4a7df 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.git.LockFailureException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -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());