Sorry, 100% agreement with sebb. I read the attribution wrong :-)

On Tue, Apr 19, 2011 at 10:26 AM, Paul Benedict <pbened...@apache.org>wrote:

> I carried my Effective Java 2nd Edition book in to work today.
>
> It's item #7. On Page 29 says, Josh says, "While there is no guarantee
> that the finalizer will be invoked promptly, it may be better to free the
> resource
> late than never, in those (hopefully rare) cases where the client fails to
> call
> the explicit termination method. But the finalizer should log a warning if
> it
> finds that the resource has not been terminated"
>
>
> On Tue, Apr 19, 2011 at 10:13 AM, sebb <seb...@gmail.com> wrote:
>
>> On 19 April 2011 16:00, Torsten Curdt <tcu...@vafer.org> 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: dev-unsubscr...@commons.apache.org
>> > For additional commands, e-mail: dev-h...@commons.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>>
>

Reply via email to