public class FailWriteEveryThirdRequest extends ConfigCache{
Map<String, String> map = new HashMap<>();
AtomicInteger counter = new AtomicInteger(1);
@Override
protected String read(String key) throws Exception {
return map.get(key);
}
@Override
protected void write(String key, String value) throws Exception {
if(counter.getAndIncrement() % 2 == 0){
throw new RuntimeException("I fail for some reason"); // just to mimic exception on failure writing
}
map.put(key, value);
}
}
Update the value and refresh -> everything good -> before refresh for the second time (that will throw exception):
At minimum, when fail to write to cache, the next successful refresh (done manually) should be able to update the value.
Better solution is server can know when there is a problem on writing and when client use webhook, server can do retry mechanism.
Default configuration also can reproduce. (Just use manual polling and manual force refresh)