summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-04-22 22:21:20 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2022-04-22 22:22:41 +0200
commitb4ebcfced53c1f4d4e9bcd885978c276fc55070f (patch)
treeda4661e6d87f909e56b295e028412046a4601641
parent44171b65a0c1c390764cdd045aff1cd138c4b802 (diff)
parent6e04fc32f87780e949c4213a6f028cc0d6a0c575 (diff)
Merge branch 'stable-3.3' into stable-3.4v3.4.8v3.4.7v3.4.6v3.4.5upstream/stable-3.4
* origin/stable-3.3: Do not retry replication when local repository not found Change-Id: I6a8d0650ca24a4aac86fdafc819b028cf8864332
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java6
-rw-r--r--src/test/java/com/googlesource/gerrit/plugins/replication/PushOneTest.java13
2 files changed, 18 insertions, 1 deletions
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 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning, UriUpdates {
"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.Callable;
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 @@ public class PushOneTest {
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(