I don't think these are redundant. RandomAccessFile is used by FSDirectory.FSInputStream and FSDirectory.FSOutputStream and doesn't have a finalizer. If these finalizers never existed, I'd say we wouldn't need them as broken code that didn't call close would already be failing. At this point, we have a backwards compatibility problem if they are removed.
IndexReader and IndexWriter finalizers attempt to guarantee lock file cleanup. Again there is potential for backwards compatibility issues if these are removed and there is code that isn't calling close explicitly. If the backwards compatiblity wasn't an issue, I would add deleteOnExit when the lock files are created in FSDirectory to cover this one instead of using a finalizer. Eric -----Original Message----- From: Doug Cutting [mailto:[EMAIL PROTECTED] Sent: Friday, February 20, 2004 11:49 AM To: Lucene Developers List Subject: Re: Lucene's finalizeable objects Eric Isakson wrote: > These all look appropriate to me. These finalizers protect against a > program consuming system resources if a programmer forgets to call > close and the object gets garbage collected. This is similar to the > handling by java.io.FileInputStream and java.io.FileOutputStream see: > > http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html# > finalize() I never noticed that. Thanks for pointing it out! The presence of this probably makes Lucene's finalize() methods redundant, doesn't it? > In a perfect world, these wouldn't be needed and people would always > call close before the objects become unreachable. Having to call close() is like malloc/free or new/delete in C and C++, i.e., in an ideal world we shouldn't have to call them. It's only required here because the OS isn't integrated with Java's GC. But finalize() provides the hook to perform this integration. Doug --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]