HttpServer should implement AutoCloseable?
Alan Bateman
alan.bateman at oracle.com
Fri Oct 24 05:56:53 UTC 2025
On 23/10/2025 23:09, David Alayachew wrote:
> Hello @core-libs-dev <mailto:core-libs-dev at openjdk.org>,
>
> Would it be ok if we made HttpServer from the jdk.httpserver module
> implement AutoCloseable? Having this would prevent people from
> forgetting to close the server after use.
>
> The close() implementation could call stop(int delay) with a
> reasonable default. This implementation should be a default one, so
> that existing child classes that also implemented AutoCloseable lose
> no functionality.
>
The net-dev mailing list is where networking and HTTP issues are usually
discussed. HttpExchange was retrofitted to implement AutoCloseable in
JDK 14 and there may have been discussed (can't remember) about
HttpServer at the time.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20251024/4d19fea0/attachment.htm>
More information about the core-libs-dev
mailing list