Description
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.