Fixed - Intermittent Exception when creating RedissonLocalCachedMap (regression since 3.24.1) #5385

pull/5399/head
Nikita Koksharov 1 year ago
parent 106fbea55f
commit 8223c05b96

@ -280,7 +280,7 @@ public class PublishSubscribeService {
return;
}
long newTimeout = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
long newTimeout = timeout - TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
subscribeNoTimeout(codec, channelName, entry, clientEntry, promise, type, lock, new AtomicInteger(), listeners);
timeout(promise, newTimeout);
});

@ -30,6 +30,9 @@ import java.io.IOException;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
@ -143,6 +146,26 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
assertThat(entries.values()).containsOnly(null, null);
}
@Test
public void testSubscriptionTimeout() {
Config config = new Config();
config.useSingleServer()
.setSubscriptionsPerConnection(2)
.setSubscriptionConnectionPoolSize(1)
.setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedissonClient redisson = Redisson.create(config);
RLocalCachedMap<Object, Object> m1 = redisson.getLocalCachedMap("pubsub_test1", LocalCachedMapOptions.defaults());
ScheduledExecutorService e = Executors.newSingleThreadScheduledExecutor();
e.schedule(() -> {
m1.destroy();
}, 1, TimeUnit.SECONDS);
RLocalCachedMap<Object, Object> m2 = redisson.getLocalCachedMap("pubsub_test2", LocalCachedMapOptions.defaults());
redisson.shutdown();
}
@Test
public void testExpiration() throws IOException, InterruptedException {
RedisRunner.RedisProcess instance = new RedisRunner()
@ -520,10 +543,10 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
.cacheSize(5)
.syncStrategy(SyncStrategy.INVALIDATE);
RLocalCachedMap<String, Integer> map1 = redisson.getLocalCachedMap("test", options);
RLocalCachedMap<String, Integer> map1 = redisson.getLocalCachedMap("testLocalCacheClear", options);
Map<String, Integer> cache1 = map1.getCachedMap();
RLocalCachedMap<String, Integer> map2 = redisson.getLocalCachedMap("test", options);
RLocalCachedMap<String, Integer> map2 = redisson.getLocalCachedMap("testLocalCacheClear", options);
Map<String, Integer> cache2 = map2.getCachedMap();
map1.put("1", 1);

Loading…
Cancel
Save