commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandy McArthur" <sandy...@apache.org>
Subject Re: [io] LineIterator finalize
Date Sun, 05 Mar 2006 19:17:02 GMT
On 3/5/06, Stephen Colebourne <scolebourne@btopenworld.com> wrote:
> Sandy McArthur wrote:
> > I don't think LineIterator should have a finalizer method and I
> > believe the JavaDocs in that class about resource leaks are wrong and
> > unnecessarily alarming.
>
> Here is the problem as I see it.
>
> Create a LineIterator.
> Start using it.
> An exception is thrown.
> The LineIterator is not closed.
>
> (assumes the user doesn't write the finally clause as the javadoc tells
> them to)
>
> This would appear to be a resource leak situation, as the underlying
> reader, which the iterator wraps, is still open.

Okay, but once the LineIterator instance is no longer strongly
reachable it will be garbage collected. This will then make the Reader
instance no longer strongly reachable and it will be garbage
collected. When the Reader instance is collected then there are no
leaked resources.

--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

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


Mime
View raw message