[console] 修复在Android系统运行时,被杀后台时抛出的 InterruptedException 导致崩溃 (#2474)

* 修复在Android系统运行时,被杀后台时抛出的 InterruptedException 导致崩溃

* Update mirai-console/backend/mirai-console/src/MiraiConsoleImplementation.kt

Co-authored-by: Him188 <Him188@mamoe.net>

---------

Co-authored-by: Him188 <Him188@mamoe.net>
This commit is contained in:
赵怡然 2023-03-02 01:57:57 +08:00 committed by GitHub
parent a6afd9540c
commit cb78ed34a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -449,8 +449,12 @@ public interface MiraiConsoleImplementation : CoroutineScope {
init {
Runtime.getRuntime().addShutdownHook(thread(false, name = "Mirai Console Shutdown Hook") {
if (instanceInitialized) {
runBlocking {
shutdown()
try {
runBlocking {
shutdown()
}
} catch (_ : InterruptedException) {
}
}
})
@ -509,4 +513,4 @@ public interface MiraiConsoleImplementation : CoroutineScope {
}
}
}
}
}