From 1390e68465bdff3b56f0cb746126e249ce866033 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 28 Oct 2015 11:05:00 -0400 Subject: [PATCH] Fix test bug in CacheTests#testDependentKeyDeadlock --- .../java/org/elasticsearch/common/cache/CacheTests.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java b/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java index 29e741e47ac..61ba2efebba 100644 --- a/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java +++ b/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java @@ -542,7 +542,14 @@ public class CacheTests extends ESTestCase { for (int j = 0; j < numberOfEntries; j++) { Key key = new Key(random.nextInt(numberOfEntries)); try { - cache.computeIfAbsent(key, k -> k.key != 0 ? cache.get(new Key(k.key / 2)) : 0); + cache.computeIfAbsent(key, k -> { + if (k.key == 0) { + return 0; + } else { + Integer value = cache.get(new Key(k.key / 2)); + return value != null ? value : 0; + } + }); } catch (ExecutionException e) { fail(e.getMessage()); }