Remove the NewProjectCreatedListener implementation Initial version of this plugin implemented the NewProjectCreatedListener in order to create missing repositories in the replication targets. This was the only way how replication plugin created missing repositories. Since I4e587cdfca09445c9b1c528b2f1edae0944aec68, if during the replication of a ref it is found that the repository missing on the remote site it will be automatically created. This means, that since that change there are two ways a repository is created on the remote site: 1: from the NewProjectCreatedListener.onNewProjectCreated 2: during ref replication when the repository is missing There are two major differences in how cases 1 and 2 are invoked. In the case 1 the remote repository creation is performed from the calling thread, which means from the Gerrit core thread which invokes NewProjectCreatedListener(s). In the case 2, the creation of the remote repository is done from the replication queue thread which was processing the ref replication. Note that replication tasks are created with an additional child injector [1] which provides additional bindings available for injection into the classes implementing the replication and repository creation. These binding are, however, not available when the repository creation is processed from the Gerrit core thread invoking NewProjectCreatedListener(s). Removing the NewProjectCreatedListener implementation removes this asymmetry and makes sure that all replication relevant steps, including repository creation, are processed from replication queue threads. [1] https://gerrit.googlesource.com/plugins/replication/+/871da5aa023bdfd03a3b943f7f6b82c7e0f16341/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java#189 Change-Id: I32e7aa632ffe0e94eb525f7f2c007fbb88569004 (cherry picked from commit c16fe9c5a6da6c23dbf45a533f788dcc527e209c)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java index 1405a12..464e37a 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java
@@ -21,7 +21,6 @@ import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.extensions.events.HeadUpdatedListener; import com.google.gerrit.extensions.events.LifecycleListener; -import com.google.gerrit.extensions.events.NewProjectCreatedListener; import com.google.gerrit.extensions.events.ProjectDeletedListener; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.server.events.EventTypes; @@ -41,7 +40,6 @@ .to(ReplicationQueue.class); DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(ReplicationQueue.class); - DynamicSet.bind(binder(), NewProjectCreatedListener.class).to(ReplicationQueue.class); DynamicSet.bind(binder(), ProjectDeletedListener.class).to(ReplicationQueue.class); DynamicSet.bind(binder(), HeadUpdatedListener.class).to(ReplicationQueue.class);
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 03b7ad2..2c62b4e 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -21,7 +21,6 @@ import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.extensions.events.HeadUpdatedListener; import com.google.gerrit.extensions.events.LifecycleListener; -import com.google.gerrit.extensions.events.NewProjectCreatedListener; import com.google.gerrit.extensions.events.ProjectDeletedListener; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.reviewdb.client.Project; @@ -43,7 +42,6 @@ public class ReplicationQueue implements LifecycleListener, GitReferenceUpdatedListener, - NewProjectCreatedListener, ProjectDeletedListener, HeadUpdatedListener { static final String REPLICATION_LOG_NAME = "replication_log"; @@ -161,14 +159,6 @@ } @Override - public void onNewProjectCreated(NewProjectCreatedListener.Event event) { - Project.NameKey projectName = new Project.NameKey(event.getProjectName()); - for (URIish uri : getURIs(projectName, FilterType.PROJECT_CREATION)) { - createProject(uri, projectName, event.getHeadName()); - } - } - - @Override public void onProjectDeleted(ProjectDeletedListener.Event event) { Project.NameKey projectName = new Project.NameKey(event.getProjectName()); for (URIish uri : getURIs(projectName, FilterType.PROJECT_DELETION)) {