From 2f60ce2aa7d40084fbcbafb6d29514731cceaebb Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Tue, 16 Aug 2016 22:58:06 -0400 Subject: [PATCH] Fix bad logic in MaxMind circuit breaker processor (no clue what I was thinking when I first wrote it) --- .../net/frozenorb/apiv3/util/MaxMindUtils.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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); } });