Fix bad logic in MaxMind circuit breaker processor (no clue what I was thinking when I first wrote it)

This commit is contained in:
Colin McDonald 2016-08-16 22:58:06 -04:00
parent 831348b4f8
commit 2f60ce2aa7
1 changed files with 11 additions and 4 deletions

View File

@ -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);
}
});