Detailed description
During simulated heartbeat sending, when trying to catch IOExceptions in the SseEmiter.send operation, I found that while I could catch IOExceptions that occurred when the client disconnected, the same IOException was still thrown on the NIO thread. I understand this is NIO behavior; asynchronous operations cannot be caught on different threads. However, what I don't understand is that when I use the SLF4J logging library for logging output in the captured code block, the NIO logs are still printed. But when I don't use a logging library for output (e.g., using the print function), or don't perform any operation, the NIO logs are not printed. Why is this? I can't understand why the NIO logs are being printed, which prevents me from better handling this problem.
Use version
- springboot : 3.5.6
- jdk: 17
Reproduction Test
- When I use
curl http://localhost:8180/none-log to test none-log, it does not print the NIO IOException log.
- When I use
curl http://localhost:8180/use-log to test use-log, it can capture errors, but it also prints NIO IOException logs.
Test Demo Repository
https://github.com/setruth/sse-exception
Detailed description
During simulated heartbeat sending, when trying to catch IOExceptions in the
SseEmiter.sendoperation, I found that while I could catch IOExceptions that occurred when the client disconnected, the same IOException was still thrown on the NIO thread. I understand this is NIO behavior; asynchronous operations cannot be caught on different threads. However, what I don't understand is that when I use the SLF4J logging library for logging output in the captured code block, the NIO logs are still printed. But when I don't use a logging library for output (e.g., using theprintfunction), or don't perform any operation, the NIO logs are not printed. Why is this? I can't understand why the NIO logs are being printed, which prevents me from better handling this problem.Use version
Reproduction Test
curl http://localhost:8180/none-logto test none-log, it does not print the NIO IOException log.curl http://localhost:8180/use-logto test use-log, it can capture errors, but it also prints NIO IOException logs.Test Demo Repository
https://github.com/setruth/sse-exception