mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 22:48:04 +01:00
Update to embedded-redis 0.9.1
This commit is contained in:
@@ -20,6 +20,7 @@ import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguration;
|
||||
import org.whispersystems.textsecuregcm.configuration.RetryConfiguration;
|
||||
import redis.embedded.RedisServer;
|
||||
import redis.embedded.exceptions.EmbeddedRedisException;
|
||||
|
||||
public class RedisServerExtension implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback, AfterEachCallback {
|
||||
|
||||
@@ -52,7 +53,7 @@ public class RedisServerExtension implements BeforeAllCallback, BeforeEachCallba
|
||||
.port(getAvailablePort())
|
||||
.build();
|
||||
|
||||
redisServer.start();
|
||||
startWithRetries(3);
|
||||
}
|
||||
|
||||
public static RedisURI getRedisURI() {
|
||||
@@ -96,4 +97,16 @@ public class RedisServerExtension implements BeforeAllCallback, BeforeEachCallba
|
||||
return socket.getLocalPort();
|
||||
}
|
||||
}
|
||||
|
||||
private void startWithRetries(int attemptsLeft) throws Exception {
|
||||
try {
|
||||
redisServer.start();
|
||||
} catch (final EmbeddedRedisException e) {
|
||||
if (attemptsLeft == 0) {
|
||||
throw e;
|
||||
}
|
||||
Thread.sleep(500);
|
||||
startWithRetries(attemptsLeft - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user