Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class RedisOffsetBackingStore extends MemoryOffsetBackingStore {

private RedisOffsetBackingStoreConfig config;

private RedisClient client;
private volatile RedisClient client;

public RedisClient getRedisClient() {
return client;
Expand Down Expand Up @@ -99,6 +99,9 @@ public synchronized void stop() {
void load() {
// fetch the value from Redis
Map<String, String> offsets = Uni.createFrom().item(() -> {
if (client == null) {
throw new RedisClientConnectionException(new RuntimeException("Redis client is null"));
}
return (Map<String, String>) client.hgetAll(config.getRedisKeyName());
})
// handle failures and retry
Expand Down Expand Up @@ -142,6 +145,9 @@ protected void save() {
byte[] value = (mapEntry.getValue() != null) ? mapEntry.getValue().array() : null;
// set the value in Redis
Uni.createFrom().item(() -> {
if (client == null) {
throw new RedisClientConnectionException(new RuntimeException("Redis client is null"));
}
return (Long) client.hset(config.getRedisKeyName().getBytes(), key, value);
})
// handle failures and retry
Expand Down