dev@grizzly.java.net

Re: [grizzly~svn:5418] + Optimize memory management (together with Ryan)

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Tue, 30 Nov 2010 11:05:45 +0100

Hi Matt,

>> + In HTTP, HTTP-SERVER modules use Iterators instead of Enumerators
>>
>
> Would it be possible to return Collections or, at the very least,
> Iterables instead of Iterators? It's a bit of a pain when an API
> returns Iterator because client code is unnecessarily complex. For
> example:
> final Iterator<String> names = request.getHeaderNames();
> while (names.hasNext())
> {
> final String name = names.next();
> final String value = request.getHeader(name);
> ...
> }
> Instead of:
> for (String name : request.getHeaderNames())
> {
> final String value = request.getHeader(name);
> ...
I'd like to return List, but it will work good only for
request.getHeaderNames(), but request.getHeaders(String), which
theoretically should return the same type of Collection, is a problem,
cause it will make lazy iterating impossible (we will need to
precalculate all the header values at once).

As for Iterable - agree, will change it.

Thank you!

WBR,
Alexey.

> Matt
>
>