Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8AF7A10A27 for ; Tue, 16 Apr 2013 20:53:16 +0000 (UTC) Received: (qmail 46191 invoked by uid 500); 16 Apr 2013 20:53:16 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 45987 invoked by uid 500); 16 Apr 2013 20:53:16 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 45977 invoked by uid 99); 16 Apr 2013 20:53:16 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Apr 2013 20:53:15 +0000 Date: Tue, 16 Apr 2013 20:53:15 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [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 ) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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