Skip to content

Commit 64d7ddf

Browse files
committed
Revert "Use try-with-resources for httpExchange"
This reverts commit 9a11593.
1 parent 9a11593 commit 64d7ddf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/com/github/arteam/embedhttp/EmbeddedHttpServer.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public EmbeddedHttpServer start(InetSocketAddress address) {
6666

6767
for (HttpHandlerConfig config : handlers) {
6868
HttpContext context = sunHttpServer.createContext(config.path, httpExchange -> {
69-
try (httpExchange) {
69+
try {
7070
Headers requestHeaders = httpExchange.getRequestHeaders();
7171
HttpResponse response = new HttpResponse();
7272
config.httpHandler.handle(new HttpRequest(httpExchange.getRequestMethod(),
@@ -80,6 +80,8 @@ public EmbeddedHttpServer start(InetSocketAddress address) {
8080
httpExchange.getResponseBody().write(byteBody);
8181
} catch (IOException e) {
8282
e.printStackTrace();
83+
} finally {
84+
httpExchange.close();
8385
}
8486
});
8587
if (config.authenticator != null) {

0 commit comments

Comments
 (0)