maxWait in Throttle can fail.
-----------------------------
Key: IBATIS-458
URL: https://issues.apache.org/jira/browse/IBATIS-458
Project: iBatis for Java
Issue Type: Bug
Reporter: Niclas Hedhman
Priority: Minor
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.");
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.