commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject Re: svn commit: r1094856 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/
Date Tue, 19 Apr 2011 15:13:31 GMT
On 19 April 2011 16:00, Torsten Curdt <> wrote:
> I am really not comfortable doing all this stuff in finalize. Why use
> finalize at all?
> If someone forgot a close then he has to find and fix this in his code.
> Darn. Cannot find the reference I am thinking of why using "finalize"
> usually is really a bad idea. Was it from Bloch? Can't remember.

Bloch does say that generally finalizers should not be used..

However, he does say that they can be useful for "safety nets" in case
the object owner forgets to terminate it.
Better late than never.
In which case he says the finalizer should log a warning if the
resource has not been correctly terminated.

This is exactly what we are doing here.

> cheers,
> Torsten
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message