lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <Eric.Isak...@sas.com>
Subject RE: Lucene's finalizeable objects
Date Fri, 20 Feb 2004 16:33:30 GMT
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()

All finalizers are not evil, though most of the time you should avoid them if you can.

In a perfect world, these wouldn't be needed and people would always call close before the
objects become unreachable. We all know the world isn't prefect and removing these could have
serious negative consequences (running out of file handles) on programs that rely on these
finalizers.

Eric

-----Original Message-----
From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com] 
Sent: Friday, February 20, 2004 8:17 AM
To: Lucene Developers List
Subject: Lucene's finalizeable objects


An interesting article from a person known to lucene-dev:

  http://www-106.ibm.com/developerworks/library/j-jtp01274.html

I only skimmed the article, and only read the section about finalizeable objects.

Lucene has several:

$ ffjg finalize
./index/IndexWriter.java:  protected void finalize() throws IOException {
./index/IndexReader.java:  protected final void finalize() throws IOException {
./store/FSDirectory.java:  protected final void finalize() throws IOException {
./store/FSDirectory.java:  protected final void finalize() throws IOException {

Then I read the following, and noticed the "FinalizeDoesNotCallSuperFinalize" rule:

  http://pmd.sourceforge.net/rules/finalizers.html

Then I looked at Lucene's finalize() methods and noticed that none of them call super.finalize().

Now I'm wondering if they should.
I don't know enough about it to make strong statements, only point this out to those who may
know more, and can offer advice.

Otis


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message