[ 
https://issues.apache.org/jira/browse/IO-591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved IO-591.
--------------------------------
    Fix Version/s: 2.23.0
       Resolution: Fixed

> Tailer has issue if a file is not logged to after rotating the file and 
> second rotation occurs.
> -----------------------------------------------------------------------------------------------
>
>                 Key: IO-591
>                 URL: https://issues.apache.org/jira/browse/IO-591
>             Project: Commons IO
>          Issue Type: Bug
>            Reporter: chris humphrey
>            Priority: Major
>             Fix For: 2.23.0
>
>
> We are using the org.apache.commons.io.input.Tailer for scrapping logs as 
> another system generates the logs.  Generally, our logs will rotate at 
> midnight each night, sometimes no data will be sent to a log file for more 
> than a day, this is where the problem comes in.
> If the Tailer is working on a file and it is rotated, everything works fine 
> unless the file is not written to before the next rotation.  Looking at 
> Tailer.java beginning at line 457, there is a conditional "if (length > 
> position)"... "else if (newer) {"
> anytime the code gets into the "else if (newer) {" block is when this issue 
> will occur.
> The issue was noticed in a second hand way, and commented in the file
> /* ... This can happen if the file is truncated or overwritten... */
> So, in this block, the file has been Rotated, but, there is no place in this 
> block where the RandomAccessFile is re-created with the 'new' underlying 
> file. 
> Anything written into the new file will be noticed because above, the File is 
> used, but, when the code attempts to read from the file, it will never get 
> the data written.
> There are multiple ways to fix this, one work around is to set reOpen to 
> true.  Unfortunately, this is not a good workaround for us as the files we 
> are scraping can get very large, seeking to large files every 500ms is not a 
> great way for our production servers to spend their time.
>  
> The real fix is to rebuild the RandomAccessFile as it is done beginning on 
> line 437 of the same file.  
>  
> I can make changes and propose them but have never submitted changes for 
> Apache open source and would need some guidance on the process.
>  
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to