Proposal: Automatic Resource Management
Rémi Forax
forax at univ-mlv.fr
Tue Sep 1 16:24:44 PDT 2009
This will require to introduce a new interface IterableDisposable or
something like that to ease the use of such pattern.
Also note that nio2 API java.nio.file.DirectoryStream is already
an iterable/disposable (using Closable instead of Disposable).
Rémi
Le 01/09/2009 23:51, Joshua Bloch a écrit :
> Sean,
> Thanks for the suggestion.
>
> Josh
>
> On Tue, Sep 1, 2009 at 9:30 AM, Sean R. Drucker<
> sean.drucker at frameworkplus.com> wrote:
>
>
>> Automatic Resource Management should also apply to an Iterator<?> that
>> implements Disposable<?> and is used in the enhanced for-each. So, if
>> an Iterator is connected to JDBC, once iteration ends, the close method
>> is called:
>>
>>
>> for (Row row: database.getIterable()) {
>> ...
>> }
>>
>> So, when the iterator() method is called on database, if it implements
>> Disposable<?>, then it should be disposed.
>>
>> Thanks... Sean
>>
>>
>>
>>
>>
>
More information about the coin-dev
mailing list