Merge branch 'stable-3.3' into stable-3.4 * origin/stable-3.3: Do not retry replication when local repository not found Change-Id: I6a8d0650ca24a4aac86fdafc819b028cf8864332
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 87c35ee..5e940f8 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -430,8 +430,12 @@ "Replication to %s completed in %dms, %dms delay, %d retries", uri, elapsed, delay, retryCount); } catch (RepositoryNotFoundException e) { + retryDone(); stateLog.error( - "Cannot replicate " + projectName + "; Local repository error: " + e.getMessage(), + "Cannot replicate " + + projectName + + "; Local repository does not exist: " + + e.getMessage(), getStatesAsArray()); } catch (RemoteRepositoryException e) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/PushOneTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/PushOneTest.java index 94f0dc4..4bd084d 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/PushOneTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/PushOneTest.java
@@ -14,6 +14,7 @@ package com.googlesource.gerrit.plugins.replication; +import static com.google.common.truth.Truth.assertThat; import static org.eclipse.jgit.lib.Ref.Storage.NEW; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -46,6 +47,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.eclipse.jgit.errors.NotSupportedException; +import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.ObjectId; @@ -223,6 +225,17 @@ verify(transportMock, never()).push(any(), any()); } + @Test + public void shouldNotKeepRetryingWhenRepositoryNotFound() throws Exception { + when(gitRepositoryManagerMock.openRepository(projectNameKey)) + .thenThrow(new RepositoryNotFoundException("not found")); + PushOne pushOne = createPushOne(null); + pushOne.addRef(PushOne.ALL_REFS); + pushOne.setToRetry(); + pushOne.run(); + assertThat(pushOne.isRetrying()).isFalse(); + } + private PushOne createPushOne(DynamicItem<ReplicationPushFilter> replicationPushFilter) { PushOne push = new PushOne(