Skip to content

Commit

Permalink
🐛 修复了socket关闭时机错误导致的崩溃问题
Browse files Browse the repository at this point in the history
  • Loading branch information
18445 committed Mar 9, 2023
1 parent 11a0df9 commit 8769c07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sso/src/main/java/com/redrock/sso/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ internal object Server {
continuation.invokeOnCancellation {
serverSocket.close()
}
var socket : Socket? = null
try {
val socket = serverSocket.accept()
socket.close()
serverSocket.close()
socket = serverSocket.accept()
continuation.resumeWith(Result.success(getData(socket)))
} catch (_: SocketException) {
// socket 被 serverSocket cancel 时抛出的异常
} finally {
socket?.close()
serverSocket.close()
}
}
}
Expand Down

0 comments on commit 8769c07

Please sign in to comment.