<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Hello <a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:net-dev@openjdk.org" tabindex="-1">@net-dev@openjdk.org</a>,</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">
<div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">Thank you for your time and consideration.</div><font color="#888888"><div dir="auto">David Alayachew</div></font>
<br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Oct 24, 2025 at 10:51 AM David Alayachew <<a href="mailto:davidalayachew@gmail.com">davidalayachew@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:monospace">Thanks Alan, I'll reattempt this thread over there.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 24, 2025 at 1:57 AM Alan Bateman <<a href="mailto:alan.bateman@oracle.com" target="_blank">alan.bateman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<div>On 23/10/2025 23:09, David Alayachew
wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Hello <span class="gmail_chip gmail_plusreply" dir="auto"><a href="mailto:core-libs-dev@openjdk.org" style="color:rgb(17,85,204);text-decoration:underline" target="_blank">@core-libs-dev</a></span>,
<div dir="auto"><br>
</div>
<div dir="auto">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.</div>
<div dir="auto"><br>
</div>
<div dir="auto">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.</div>
<br>
</div>
</blockquote>
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.<br>
<br>
-Alan<br>
</div>
</blockquote></div>
</blockquote></div>