lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <>
Subject RE: Lucene's finalizeable objects
Date Fri, 20 Feb 2004 17:50:31 GMT
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.


-----Original Message-----
From: Doug Cutting [] 
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 and see:
> 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.


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

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

View raw message