Fixed MapLoader hangs if loaded value is null. #1170

pull/1204/head
Nikita 7 years ago
parent 353f9aa24d
commit a98118221f

@ -1185,7 +1185,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
public void run() { public void run() {
final V value = options.getLoader().load(key); final V value = options.getLoader().load(key);
if (value == null) { if (value == null) {
result.trySuccess(value); unlock(result, lock, threadId, value);
return; return;
} }

@ -19,6 +19,19 @@ public abstract class BaseMapTest extends BaseTest {
protected abstract <K, V> RMap<K, V> getLoaderTestMap(String name, Map<K, V> map); protected abstract <K, V> RMap<K, V> getLoaderTestMap(String name, Map<K, V> map);
@Test
public void testMapLoaderGetMulipleNulls() {
Map<String, String> cache = new HashMap<String, String>();
cache.put("1", "11");
cache.put("2", "22");
cache.put("3", "33");
RMap<String, String> map = getLoaderTestMap("test", cache);
assertThat(map.get("0")).isNull();
assertThat(map.get("1")).isEqualTo("11");
assertThat(map.get("0")).isNull(); // This line will never return anything and the test will hang
}
@Test @Test
public void testWriterAddAndGet() { public void testWriterAddAndGet() {
Map<String, Integer> store = new HashMap<>(); Map<String, Integer> store = new HashMap<>();

Loading…
Cancel
Save