Madan Jampani

CachingAsyncConsistentMap: evict failed get responses from cache

AtomixLeaderElector: evict failed getLeadership responses from cache immediately

Change-Id: I084abbe8f4669b98f85bc60dc6af9240630b7ce0
(cherry picked from commit 77012446)
......@@ -95,7 +95,12 @@ public class CachingAsyncConsistentMap<K, V> extends DelegatingAsyncConsistentMa
@Override
public CompletableFuture<Versioned<V>> get(K key) {
return cache.getUnchecked(key);
return cache.getUnchecked(key)
.whenComplete((r, e) -> {
if (e != null) {
cache.invalidate(key);
}
});
}
@Override
......
......@@ -135,7 +135,12 @@ public class AtomixLeaderElector extends AbstractResource<AtomixLeaderElector>
@Override
public CompletableFuture<Leadership> getLeadership(String topic) {
return cache.getUnchecked(topic);
return cache.getUnchecked(topic)
.whenComplete((r, e) -> {
if (e != null) {
cache.invalidate(topic);
}
});
}
@Override
......