commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Haldane (JIRA)" <j...@apache.org>
Subject [jira] [Created] (VFS-486) DefaultFileMonitor sleeps for twice the specified delay when checkPerRun > 0
Date Fri, 09 Aug 2013 00:50:48 GMT
Sam Haldane created VFS-486:
-------------------------------

             Summary: DefaultFileMonitor sleeps for twice the specified delay when checkPerRun
> 0
                 Key: VFS-486
                 URL: https://issues.apache.org/jira/browse/VFS-486
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 2.0
            Reporter: Sam Haldane
            Priority: Minor


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:
{code:java}
            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
            }
{code}

and then at the end of the loop block:
{code:java}
            try
            {
                Thread.sleep(getDelay());
            }
            catch (InterruptedException e)
            {
                continue;
            }
{code}

Workaround is to call {{setChecksPerRun(0)}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message