Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-458

maxWait in Throttle can fail.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.3.1
    • 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.");           }

      Attachments

        Activity

          People

            cbegin Clinton Begin
            niclas Niclas Hedhman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: