Virtual Threads and Handling of Interrupted IO Exception in Socket Classes
Bahaa Zaid
bahaazaid at gmail.com
Wed Feb 12 17:05:58 UTC 2025
Hello,
I have a question about handling InterruptedIOException in net Socket classes. All these classes catch the exception and check if the thread is virtual, if so, a SocketException is thrown instead with the message “Closed by interrupt”. My question is why not just throw InterruptedIOException like platform threads? And can the caller depend on this message "Closed by interrupt” to identify an interrupted operations instead of a network error?
This is causing unexpected behavior in some areas. For example, PostgreSQL JDBC Driver is treating an interrupted operation as a network error. This in turn cause the connection pooling library to mark the connection as broken and it disposes it. Can their implementation depend on the exception message? Or in such state, the socket is not reusable anyway?
Thanks,
Bahaa.
More information about the loom-dev
mailing list