RFR: 8245095: Implementation of JEP 408: Simple Web Server

Julia Boes jboes at openjdk.java.net
Wed Sep 15 08:14:49 UTC 2021


On Tue, 14 Sep 2021 13:38:27 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java line 106:
>> 
>>> 104:         var h = headers.entrySet().stream()
>>> 105:                 .collect(Collectors.toUnmodifiableMap(
>>> 106:                         Entry::getKey, e -> new LinkedList<>(e.getValue())));
>> 
>> I wonder, what the reason of  `LinkedList` usages here?
>> As I know ArrayList is faster in all real-world scenarios.
>
> Hi Andrey, IIRC from when I reviewed this code the current implementation of `Headers` already uses `LinkedList` in other places - so this preserves the concrete list implementation class that `Headers` uses (see `Headers::add`). Not that it matters much - but if we wanted to replace `LinkedList` with `ArrayList`  I believe we should do it consistently in this class - and probably outside of the realm of this JEP.

That's right, it's due to the pre-existing implementation.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5505



More information about the build-dev mailing list