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

DefaultFileMonitor sleeps for twice the specified delay when checkPerRun > 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 2.1
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: