[
https://issues.apache.org/jira/browse/VFS-486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary Gregory resolved VFS-486.
------------------------------
Resolution: Fixed
Fix Version/s: 2.1
Thank you Sam!
{noformat}
commit -m "[VFS-486] DefaultFileMonitor sleeps for twice the specified delay
when checkPerRun > 0. Thanks to Sam Haldane."
C:/vcs/svn/apache/commons/trunks-proper/vfs/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java
Sending
C:/vcs/svn/apache/commons/trunks-proper/vfs/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java
Transmitting file data ...
Committed revision 1512537.
{noformat}
> 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
> Fix For: 2.1
>
> Attachments: VFS-486.diff
>
>
> 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