Details
-
Bug
-
Resolution: Unresolved
-
Critical
-
None
-
1.0.13, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.1.9, 1.1.10, 1.2.0, 1.2.1, 1.2.2, 1.1.11, 1.3.0-alpha0, 1.2.3, 1.3.0-alpha1, 1.3.0-alpha3, 1.3.0-alpha4, 1.3.0-alpha5, 1.2.4, 1.3.0-alpha6
-
None
-
Tested and this issue on:
- macOS 10.13.16, MacBookPro8,2, Java 11
- Ubuntu 18.04, Java 8 and Java 11
Description
ServerSocketAppender (or any appender usingĀ ConcurrentServerRunner) can emit an error when stopping. This issue is most noticeable in projects where Spring Boot is used, as Spring Boot reloads Logback config when starting and any error that occured during this reload is escalated and crashes the whole app.
Symptoms
An error containing the following message is being reported to StatusManager:
java.net.SocketException: Socket is closed
How to reproduce?
I have added a simple test that presents how to reproduce the error:
https://github.com/multicatch/logback/commit/b41a33b1ed717ed282955631f23b68dba821add5
The cause
This is due to the fact that ConcurrentServerRunner is not being interrupted when it is run by the ExecutionService and it waits for new connections even when it was instructed to stop. Finally, the ServerSocket is closed and the `accept()` method is still waiting for connections (and even if not, the loop in ConcurrentServerRunner is not breaking because the thread with the runner was not interrupted) and it causes the `SocketException`. It is then caught and added to StatusManager, and then crashes Spring Boot as this is treated as configuration error.
I have implemented a fix for this issue (https://github.com/multicatch/logback/tree/fix/server-socket-closing) and it can be cherry-picked to all affected versions.