Skip to content

Commit c892050

Browse files
committed
Always try and close the socket on SocketException.
1 parent 3a4e1df commit c892050

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/io/fusionauth/http/server/internal/HTTPWorker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,12 @@ public void run() {
256256
logger.debug("[{}] Closing socket with status [{}]. Bad request, failed to parse request. Reason [{}] Parser state [{}]", Thread.currentThread().threadId(), Status.BadRequest, e.getMessage(), e.getState());
257257
closeSocketOnError(response, Status.BadRequest);
258258
} catch (SocketException e) {
259-
// This should only happen when the server is shutdown and this thread is waiting to read or write. In that case, this will throw a
260-
// SocketException and the thread will be interrupted. Since the server is being shutdown, we should let the client know.
259+
// When the HTTPServerThread shuts down, we will interrupt each client thread, so debug log it accordingly.
260+
// - This will cause the socket to throw a SocketException, so log it.
261261
if (Thread.currentThread().isInterrupted()) {
262-
// Close socket only. We do not want to potentially delay the shutdown at all.
263262
logger.debug("[{}] Closing socket. Server is shutting down.", Thread.currentThread().threadId());
263+
} else {
264+
logger.debug("[{}] Closing socket. The socket by a client, proxy or otherwise.", Thread.currentThread().threadId());
264265
}
265266
closeSocketOnly(CloseSocketReason.Expected);
266267
} catch (IOException e) {

0 commit comments

Comments
 (0)