Merge branch 'stable-3.2' into stable-3.3

* stable-3.2:
  CreateProjectTask.java: use interface instead of implementation
  ReplicationQueue: Remove unused isPersisted param
  PushOne: Don't call delta.add(ref) twice

Change-Id: Idcffd9873cbc70c6aad9ed9a0e76233494c93444
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/CreateProjectTask.java b/src/main/java/com/googlesource/gerrit/plugins/replication/CreateProjectTask.java
index 424648e..2599b9b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/CreateProjectTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/CreateProjectTask.java
@@ -31,7 +31,7 @@
   }
 
   private final RemoteConfig config;
-  private final DestinationsCollection destinations;
+  private final ReplicationDestinations destinations;
   private final DynamicItem<AdminApiFactory> adminApiFactory;
   private final Project.NameKey project;
   private final String head;
@@ -39,7 +39,7 @@
   @Inject
   CreateProjectTask(
       RemoteConfig config,
-      DestinationsCollection destinations,
+      ReplicationDestinations destinations,
       DynamicItem<AdminApiFactory> adminApiFactory,
       @Assisted Project.NameKey project,
       @Assisted String head) {
@@ -51,8 +51,10 @@
   }
 
   public boolean create() {
-    return destinations.getURIs(Optional.of(config.getName()), project, FilterType.PROJECT_CREATION)
-        .values().stream()
+    return destinations
+        .getURIs(Optional.of(config.getName()), project, FilterType.PROJECT_CREATION)
+        .values()
+        .stream()
         .map(u -> createProject(u, project, head))
         .reduce(true, (a, b) -> a && b);
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index 4b155a7..3c34fb6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -242,7 +242,6 @@
       pushAllRefs = true;
       repLog.atFinest().log("Added all refs for replication to %s", uri);
     } else if (!pushAllRefs && delta.add(ref)) {
-      delta.add(ref);
       repLog.atFinest().log("Added ref %s for replication to %s", ref, uri);
     }
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
index 6fbb438..990e387 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -117,17 +117,17 @@
 
   public void scheduleFullSync(
       Project.NameKey project, String urlMatch, ReplicationState state, boolean now) {
-    fire(project, urlMatch, PushOne.ALL_REFS, state, now, false);
+    fire(project, urlMatch, PushOne.ALL_REFS, state, now);
   }
 
   @Override
   public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event event) {
-    fire(event.getProjectName(), event.getRefName(), false);
+    fire(event.getProjectName(), event.getRefName());
   }
 
-  private void fire(String projectName, String refName, boolean isPersisted) {
+  private void fire(String projectName, String refName) {
     ReplicationState state = new ReplicationState(new GitUpdateProcessing(dispatcher.get()));
-    fire(Project.nameKey(projectName), null, refName, state, false, isPersisted);
+    fire(Project.nameKey(projectName), null, refName, state, false);
     state.markAllPushTasksScheduled();
   }
 
@@ -136,8 +136,7 @@
       String urlMatch,
       String refName,
       ReplicationState state,
-      boolean now,
-      boolean isPersisted) {
+      boolean now) {
     if (!running) {
       stateLog.warn(
           "Replication plugin did not finish startup before event, event replication is postponed",
@@ -147,7 +146,7 @@
     }
 
     for (Destination cfg : destinations.get().getAll(FilterType.ALL)) {
-      pushReference(cfg, project, urlMatch, refName, state, now, isPersisted);
+      pushReference(cfg, project, urlMatch, refName, state, now);
     }
   }
 
@@ -161,7 +160,7 @@
 
   @UsedAt(UsedAt.Project.COLLABNET)
   public void pushReference(Destination cfg, Project.NameKey project, String refName) {
-    pushReference(cfg, project, null, refName, null, true, false);
+    pushReference(cfg, project, null, refName, null, true);
   }
 
   private void pushReference(
@@ -170,18 +169,15 @@
       String urlMatch,
       String refName,
       ReplicationState state,
-      boolean now,
-      boolean isPersisted) {
+      boolean now) {
     boolean withoutState = state == null;
     if (withoutState) {
       state = new ReplicationState(new GitUpdateProcessing(dispatcher.get()));
     }
     if (cfg.wouldPushProject(project) && cfg.wouldPushRef(refName)) {
       for (URIish uri : cfg.getURIs(project, urlMatch)) {
-        if (!isPersisted) {
-          replicationTasksStorage.create(
-              new ReplicateRefUpdate(project.get(), refName, uri, cfg.getRemoteConfigName()));
-        }
+        replicationTasksStorage.create(
+            new ReplicateRefUpdate(project.get(), refName, uri, cfg.getRemoteConfigName()));
         cfg.schedule(project, refName, uri, state, now);
       }
     } else {
@@ -254,7 +250,7 @@
       String eventKey = String.format("%s:%s", event.projectName(), event.refName());
       if (!eventsReplayed.contains(eventKey)) {
         repLog.atInfo().log("Firing pending task %s", event);
-        fire(event.projectName(), event.refName(), false);
+        fire(event.projectName(), event.refName());
         eventsReplayed.add(eventKey);
       }
     }