diff --git a/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java b/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java index 98db270..55549cc 100644 --- a/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java +++ b/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java @@ -50,15 +50,22 @@ public class MaxMindUtils { try { MaxMindResult maxMindResult = new MaxMindResult(bodyJson); - future.complete(maxMindResult); + + // we have to check !isComplete() because the circuit breaker's timeout might mark us as failed already + if (!future.isComplete()) { + future.complete(maxMindResult); + } } catch (Exception ignored) { - future.complete(null); + // we have to check !isComplete() because the circuit breaker's timeout might mark us as failed already + if (!future.isComplete()) { + future.complete(null); + } } }); response.exceptionHandler((error) -> { - // we have to check !failed because the circuit breaker's timeout will mark us as failed already - if (future.isComplete()) { + // we have to check !isComplete() because the circuit breaker's timeout will might us as failed already + if (!future.isComplete()) { future.fail(error); } });