[ 
https://issues.apache.org/jira/browse/IO-269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13920736#comment-13920736
 ] 

Robert Olofsson commented on IO-269:
------------------------------------

I came across this issue and noticed an inefficiency in the code of the run 
method.

With the reOpen flag set a new RandomAccessFile is always created at the end of 
the main while loop in the run method:

                if (getRun() && reOpen) {
                    reader = new RandomAccessFile(file, RAF_MODE);
                    reader.seek(position);
                }

This is unnecessary and contributes to unnecessary file locking on Windows.

If the reOpen flag is set a new RandomAccessFile should only be created when 
the length of the file or the last modification date indicate that the file 
needs to be read. 


> Tailer locks file from deletion/rename on Windows
> -------------------------------------------------
>
>                 Key: IO-269
>                 URL: https://issues.apache.org/jira/browse/IO-269
>             Project: Commons IO
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>
>         Attachments: IO-269-v2.patch, IO-269-v3.patch, IO-269.patch, 
> ReOpen.java
>
>
> The Tailer code works on Windows, except that it locks the file against 
> deletion or rename.
> The test code fails to detect this, because it fails to check if the file 
> deletion succeeds.
> This seems to be a Windows OS issue.
> A possible solution might be to keep closing and re-opening the file.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to