HttpServer should implement AutoCloseable?

David Alayachew davidalayachew at gmail.com
Fri Oct 24 14:51:39 UTC 2025


Thanks Alan, I'll reattempt this thread over there.

On Fri, Oct 24, 2025 at 1:57 AM Alan Bateman <alan.bateman at oracle.com>
wrote:

> On 23/10/2025 23:09, David Alayachew wrote:
>
> Hello @core-libs-dev <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/37698ba2/attachment.htm>


More information about the core-libs-dev mailing list