You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jonathan Creasy (JIRA)" <ji...@apache.org> on 2012/07/18 23:41:34 UTC

[jira] [Created] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Jonathan Creasy created IO-338:
----------------------------------

             Summary: When a file is rotated, finish reading previous file prior to starting new one
                 Key: IO-338
                 URL: https://issues.apache.org/jira/browse/IO-338
             Project: Commons IO
          Issue Type: Improvement
          Components: Utilities
            Reporter: Jonathan Creasy




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Posted by "Brian Tran (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13419405#comment-13419405 ] 

Brian Tran commented on IO-338:
-------------------------------

I'm not getting the error anymore when I build from code off the current trunk so I think the issue I was seeing previously was only on the stable release, which I was editing beforehand. 

This is the error I was getting from the stable release: java.lang.NoSuchMethodError: org.apache.commons.io.IOUtils.closeQuietly(Ljava/io/Closeable;)

I don't really have a good reason to set last = 0. I think it was leftover from when I was debugging the previous issue about method not found. I don't think it would change current behavior, but it doesn't have any good benefit. I'll remove it.
                
> When a file is rotated, finish reading previous file prior to starting new one
> ------------------------------------------------------------------------------
>
>                 Key: IO-338
>                 URL: https://issues.apache.org/jira/browse/IO-338
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Jonathan Creasy
>         Attachments: IO-338-trunk.patch
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417938#comment-13417938 ] 

Sebb commented on IO-338:
-------------------------

What error did you get before you swapped IOUtils.closeQuietly for the inline code?

I see now: when an active file is renamed, the reader RAF still points to the original file, but operations on the File variable will use the new file. [Luckily File#length() returns 0 if the file does not exist, so the code should not mind if it catches the window between rename and creation of the new file.]

Why does the patch set last = 0?
                
> When a file is rotated, finish reading previous file prior to starting new one
> ------------------------------------------------------------------------------
>
>                 Key: IO-338
>                 URL: https://issues.apache.org/jira/browse/IO-338
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Jonathan Creasy
>         Attachments: IO-338-trunk.patch
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Posted by "Brian Tran (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417878#comment-13417878 ] 

Brian Tran commented on IO-338:
-------------------------------

Hi everyone

I wrote the code and [~jcreasy] was patching on my behalf.

To respond to everyone's questions:

[~garydgregory] For the bug, are you referring to swapping out the call to IOUtils.closeQuietly for its method definition or that the file is not read to completion after logrotation. I didn't write unit tests for either, but am willing to do so. For the swapping out IOUtils.closeQuietly, I was getting a runtime error that stopped once I swapped the method call for the definition. For the file not reading to completion, I have a Java class that tails a file and prints to stdout. Once I rotated the file, I would get nothing out of stdout after the rotation until I made the changes seen in the patch.

[~sebb@apache.org]When the file is rotated via the change the filename strategy, the save variable is still pointing to the original file. The call file.length() refers to the new file so that's how there's still unread data in the original file even though file.length() could report 0.
                
> When a file is rotated, finish reading previous file prior to starting new one
> ------------------------------------------------------------------------------
>
>                 Key: IO-338
>                 URL: https://issues.apache.org/jira/browse/IO-338
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Jonathan Creasy
>         Attachments: IO-338-trunk.patch
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417813#comment-13417813 ] 

Sebb commented on IO-338:
-------------------------

The reason for re-opening the file here is because the file length is shorter than previously, so how can there be more data left to read? We've already read beyond the reported length of the file.
                
> When a file is rotated, finish reading previous file prior to starting new one
> ------------------------------------------------------------------------------
>
>                 Key: IO-338
>                 URL: https://issues.apache.org/jira/browse/IO-338
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Jonathan Creasy
>         Attachments: IO-338-trunk.patch
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Posted by "Jonathan Creasy (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Creasy updated IO-338:
-------------------------------

    Attachment: IO-338-trunk.patch
    
> When a file is rotated, finish reading previous file prior to starting new one
> ------------------------------------------------------------------------------
>
>                 Key: IO-338
>                 URL: https://issues.apache.org/jira/browse/IO-338
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Jonathan Creasy
>         Attachments: IO-338-trunk.patch
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-338) When a file is rotated, finish reading previous file prior to starting new one

Posted by "Gary D. Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417716#comment-13417716 ] 

Gary D. Gregory commented on IO-338:
------------------------------------

Do you have a test case, a unit test patch preferably, that shows this bug before the patch is applied?

Thank you,
Gary
                
> When a file is rotated, finish reading previous file prior to starting new one
> ------------------------------------------------------------------------------
>
>                 Key: IO-338
>                 URL: https://issues.apache.org/jira/browse/IO-338
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Jonathan Creasy
>         Attachments: IO-338-trunk.patch
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira