Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
there has some code in isOpen method, as following:
if (circuitOpen.compareAndSet(false, true)) { circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()); return true; } else { return true; }
if thread one invokes the circuitOpen.compareAndSet(false, true) yet but not start invoke circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()),and thread two return true at
the same time, then thread two will invoke allowSingleTest() and get circuitOpenedOrLastTestedTime
but it is 0, because thread one not finish to invoke circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()),
so that there will be a very little time during thread one finish to invoke circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()) allowSingleTest() always return true.
I think this is a little bug.
there has some code in isOpen method, as following:
if (circuitOpen.compareAndSet(false, true)) { circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()); return true; } else { return true; }
if thread one invokes thecircuitOpen.compareAndSet(false, true)
yet but not start invokecircuitOpenedOrLastTestedTime.set(System.currentTimeMillis())
,and thread tworeturn true
at the same time, then thread two will invoke allowSingleTest() and getcircuitOpenedOrLastTestedTime
but it is 0, because thread one not finish to invokecircuitOpenedOrLastTestedTime.set(System.currentTimeMillis())
, so that there will be a very little time during thread one finish to invokecircuitOpenedOrLastTestedTime.set(System.currentTimeMillis())
allowSingleTest() always return true. I think this is a little bug.