Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-486

DefaultFileMonitor sleeps for twice the specified delay when checkPerRun > 0

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Labels:
      None

      Description

      There's a bug in DefaultFileMonitor that causes the monitor thread to sleep twice if getChecksPerRun() > 0. DefaultFileMonitor.checksPerRun defaults to 1000.

      In the main loop:

                  for (int iterFileNames = 0; iterFileNames < fileNames.length; iterFileNames++)
                  {
                      // do some stuff
                      if (getChecksPerRun() > 0)
                      {
                          if ((iterFileNames % getChecksPerRun()) == 0)
                          {
                              try
                              {
                                  Thread.sleep(getDelay());
                              }
                              catch (InterruptedException e)
                              {
                                  // Woke up.
                              }
                          }
                      }
                      // do more stuff
                  }
      

      and then at the end of the loop block:

                  try
                  {
                      Thread.sleep(getDelay());
                  }
                  catch (InterruptedException e)
                  {
                      continue;
                  }
      

      Workaround is to call setChecksPerRun(0).

        Attachments

        1. VFS-486.diff
          0.6 kB
          Sam Haldane

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                shaldane Sam Haldane
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: