lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Directory.deleteFile confusingly throws IOException
Date Wed, 21 Apr 2010 15:32:48 GMT
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

Mime
View raw message