Update to embedded-redis 0.9.1

This commit is contained in:
Chris Eager 2024-10-18 15:37:29 -05:00 committed by Chris Eager
parent 93b7fd589e
commit c6843c1eae
2 changed files with 15 additions and 2 deletions

View File

@ -266,7 +266,7 @@
<dependency>
<groupId>org.signal</groupId>
<artifactId>embedded-redis</artifactId>
<version>0.9.0</version>
<version>0.9.1</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -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);
}
}
}