You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2013/04/16 22:53:15 UTC

[jira] [Updated] (IO-340) The use of file.exists() is failure prone. Where file.exists() is checked, it should be replaced with the following dual check: exists = ( file.exists() || file.length()>0 )

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

Sebb updated IO-340:
--------------------

    Issue Type: New Feature  (was: Bug)
    
> The use of file.exists() is failure prone. Where file.exists() is checked, it should be replaced with the following dual check:  exists = ( file.exists() || file.length()>0 )
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: IO-340
>                 URL: https://issues.apache.org/jira/browse/IO-340
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>    Affects Versions: 2.5, 3.x
>         Environment: All
>            Reporter: Feeling Groovy
>              Labels: File, exists, false
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> The use of file.exists() is failure prone. In many cases the jvm can report that a file does not exist even when it does. This is due to the caching in the operating system.
> Since file.exists() is prone to report false values, a second check can and should be made to file.length()>0.
> Where file.exists() is checked, it should be replaced with the following dual check:  
> A file more reliably exists if:  file.exists() || file.length()>0
> Then if the file does not exist, file.length will be 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