Hello,

Sending a follow up email since I haven't heard back. If this idea is not
wanted, please do lmk. It just felt like a good enough semantic fit that it
was worth doing.

On Fri, Oct 24, 2025 at 10:56 AM David Alayachew <[email protected]>
wrote:

> Hello @[email protected] <[email protected]>,
>
> 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. Also, there appears to be prior precedent
> with HttpExchange.
>
> 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.
>
> Thank you for your time and consideration.
> David Alayachew
>
>
> On Fri, Oct 24, 2025 at 10:51 AM David Alayachew <[email protected]>
> wrote:
>
>> Thanks Alan, I'll reattempt this thread over there.
>>
>> On Fri, Oct 24, 2025 at 1:57 AM Alan Bateman <[email protected]>
>> wrote:
>>
>>> On 23/10/2025 23:09, David Alayachew wrote:
>>>
>>> Hello @core-libs-dev <[email protected]>,
>>>
>>> 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
>>>
>>

Reply via email to