Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
A possible bug, where it waits for the timeout:
LOCK.wait(maxWait - totalWaitTime);
this is ok for the first time round the loop because maxWait is > 0 and totalWaitTime == 0
however, the subsequent check, for when the thread is interrupted mid-wait, is as follows:
if (totalWaitTime > maxWait)
{ throw new RuntimeException("Throttle waited too long (" + totalWaitTime + " milliseconds) for lock."); }if totalWaitTime == maxWait then the loop will continue, and the thread will wait again at:
LOCK.wait(maxWait - totalWaitTime);
but now the remaining timeout is zero, which means wait forever!
The fix would be;
if (totalWaitTime >= maxWait)
{ throw new RuntimeException("Throttle waited too long (" + totalWaitTime + " milliseconds) for lock."); }