lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: Directory.deleteFile confusingly throws IOException
Date Wed, 21 Apr 2010 16:01:38 GMT
I agree clarity is important so we should tighten up this spec.

But, don't we potentially lose information if we just return true or
false?  (Ie why the deletion failed).  Failing because of FNFE vs a
"permission denied" or filesystem corruption are very different.  But,
then, our hands are tied anyway since File.delete returns boolean...
so maybe we should simply return a boolean...?


On Wed, Apr 21, 2010 at 11:32 AM, Shai Erera <> wrote:
> Hi
> While working on LUCENE-2402, I've noticed what I think is a confusing
> behavior of Dir.deleteFile. Its signature declares throwing an IOException,
> but w/ no documentation to when and why will this be thrown. And then of
> course there are the two different implementations by FSDir and RAMDir:
> FSDir throws an IOException if File.delete() returns false while RAMDir
> throws FNFE if the file does not exist.
> In either case, an IOE is not thrown from the lower-level API (File in FSDir
> case).
> Then, IFD.deleteFile declares "throws IOException", but never really throws
> it. Instead, it calls directory.deleteFile(), catches IOE, and calls
> dir.fileExists. If the latter returns true it adds the file to the list of
> pending to delete files, otherwise simply ignores the exception (!?).
> My feeling is that this exception should not be declared on Directory, but
> rather have deleteFile return true or false (like Java's File). In both
> current implementations, it's not a real IO error, and if there is any
> custom Dir impl out there, which really throws IOE, then IFD clearly ignores
> it, and will try to delete the file again next time.
> So it's more that Dir.deleteFile is confusing, than IFD is broken. And I
> think clarity is important.
> What do you think?
> Shai

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message