Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 51060 invoked from network); 11 Apr 2010 22:40:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Apr 2010 22:40:06 -0000 Received: (qmail 76588 invoked by uid 500); 11 Apr 2010 22:40:06 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 76449 invoked by uid 500); 11 Apr 2010 22:40:05 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 76442 invoked by uid 99); 11 Apr 2010 22:40:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 22:40:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 22:40:03 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o3BMdf8Z020301 for ; Sun, 11 Apr 2010 18:39:41 -0400 (EDT) Message-ID: <22519926.13051271025581174.JavaMail.jira@thor> Date: Sun, 11 Apr 2010 18:39:41 -0400 (EDT) From: "Earwin Burrfoot (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Commented: (LUCENE-2316) Define clear semantics for Directory.fileLength In-Reply-To: <156817700.245141268489487313.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LUCENE-2316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12855787#action_12855787 ] Earwin Burrfoot commented on LUCENE-2316: ----------------------------------------- I like Marvin's suggestion - deprecate/delete Dir.fileLength, and rely on InStream.length if needed (I believe if we actually open the file for reading, NFS gives us the correct length?). If not - throw FNFE, and go for backcompat break instead of new/deprecate cycle. > Define clear semantics for Directory.fileLength > ----------------------------------------------- > > Key: LUCENE-2316 > URL: https://issues.apache.org/jira/browse/LUCENE-2316 > Project: Lucene - Java > Issue Type: Improvement > Components: Index > Reporter: Shai Erera > Priority: Minor > Fix For: 3.1 > > > On this thread: http://mail-archives.apache.org/mod_mbox/lucene-java-dev/201003.mbox/%3C126142c1003121525v24499625u1589bbef4c0792e7@mail.gmail.com%3E it was mentioned that Directory's fileLength behavior is not consistent between Directory implementations if the given file name does not exist. FSDirectory returns a 0 length while RAMDirectory throws FNFE. > The problem is that the semantics of fileLength() are not defined. As proposed in the thread, we'll define the following semantics: > * Returns the length of the file denoted by name if the file exists. The return value may be anything between 0 and Long.MAX_VALUE. > * Throws FileNotFoundException if the file does not exist. Note that you can call dir.fileExists(name) if you are not sure whether the file exists or not. > For backwards we'll create a new method w/ clear semantics. Something like: > {code} > /** > * @deprecated the method will become abstract when #fileLength(name) has been removed. > */ > public long getFileLength(String name) throws IOException { > long len = fileLength(name); > if (len == 0 && !fileExists(name)) { > throw new FileNotFoundException(name); > } > return len; > } > {code} > The first line just calls the current impl. If it throws exception for a non-existing file, we're ok. The second line verifies whether a 0 length is for an existing file or not and throws an exception appropriately. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org