Skip to content

Commit

Permalink
Merge pull request #748 from mattrjacobs/fix-racy-circuit-breaker-isOpen
Browse files Browse the repository at this point in the history
Fix return value of HystrixCircuitBreakerImpl.isOpen when we lose the race to open a circuit
  • Loading branch information
mattrjacobs committed Apr 8, 2015
2 parents 657e0ec + 9bacb20 commit 623111d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ public boolean isOpen() {
// our failure rate is too high, trip the circuit
if (circuitOpen.compareAndSet(false, true)) {
// if the previousValue was false then we want to set the currentTime
// How could previousValue be true? If another thread was going through this code at the same time a race-condition could have
// caused another thread to set it to true already even though we were in the process of doing the same
circuitOpenedOrLastTestedTime.set(System.currentTimeMillis());
return true;
} else {
return false;
// How could previousValue be true? If another thread was going through this code at the same time a race-condition could have
// caused another thread to set it to true already even though we were in the process of doing the same
// In this case, we know the circuit is open, so let the other thread set the currentTime and report back that the circuit is open
return true;
}
}
}
Expand Down

0 comments on commit 623111d

Please sign in to comment.