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

Daniel Fuchs dfuchs at openjdk.java.net
Tue Sep 14 13:41:03 UTC 2021


On Tue, 14 Sep 2021 13:19:17 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

>> This change implements a simple web server that can be run on the command-line with `java -m jdk.httpserver`.
>> 
>> This is facilitated by adding an entry point for the `jdk.httpserver` module, an implementation class whose main method is run when the above command is executed. This is the first such module entry point in the JDK.
>> 
>> The server is a minimal HTTP server that serves the static files of a given directory, similar to existing alternatives on other platforms and convenient for testing, development, and debugging.
>> 
>> Additionally, a small API is introduced for programmatic creation and customization.
>> 
>> Testing: tier1-3.
>
> 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.

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

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



More information about the build-dev mailing list