Skip to content

Commit 476cccb

Browse files
authored
Merge pull request #40 from FusionAuth/degroff/close_socket_on_socket_exception
degroff/close socket on socket exception
2 parents 967a5d1 + f35212b commit 476cccb

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

build.savant

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ restifyVersion = "4.2.1"
1818
slf4jVersion = "2.0.17"
1919
testngVersion = "7.11.0"
2020

21-
project(group: "io.fusionauth", name: "java-http", version: "1.1.1", licenses: ["ApacheV2_0"]) {
21+
project(group: "io.fusionauth", name: "java-http", version: "1.1.2", licenses: ["ApacheV2_0"]) {
2222
workflow {
2323
fetch {
2424
// Dependency resolution order:

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.fusionauth</groupId>
44
<artifactId>java-http</artifactId>
5-
<version>1.1.1</version>
5+
<version>1.1.2</version>
66
<packaging>jar</packaging>
77

88
<name>Java HTTP library (client and server)</name>
@@ -200,4 +200,4 @@
200200
</build>
201201
</profile>
202202
</profiles>
203-
</project>
203+
</project>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,14 @@ 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());
264-
closeSocketOnly(CloseSocketReason.Expected);
263+
} else {
264+
logger.debug("[{}] Closing socket. The socket was closed by a client, proxy or otherwise.", Thread.currentThread().threadId());
265265
}
266+
closeSocketOnly(CloseSocketReason.Expected);
266267
} catch (IOException e) {
267268
logger.debug(String.format("[%s] Closing socket with status [%d]. An IO exception was thrown during processing. These are pretty common.", Thread.currentThread().threadId(), Status.InternalServerError), e);
268269
closeSocketOnError(response, Status.InternalServerError);

0 commit comments

Comments
 (0)