Skip to content

Commit cb78ed3

Browse files
zhaodiceHim188
andauthored
[console] 修复在Android系统运行时,被杀后台时抛出的 InterruptedException 导致崩溃 (#2474)
* 修复在Android系统运行时,被杀后台时抛出的 InterruptedException 导致崩溃 * Update mirai-console/backend/mirai-console/src/MiraiConsoleImplementation.kt Co-authored-by: Him188 <[email protected]> --------- Co-authored-by: Him188 <[email protected]>
1 parent a6afd95 commit cb78ed3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,12 @@ public interface MiraiConsoleImplementation : CoroutineScope {
449449
init {
450450
Runtime.getRuntime().addShutdownHook(thread(false, name = "Mirai Console Shutdown Hook") {
451451
if (instanceInitialized) {
452-
runBlocking {
453-
shutdown()
452+
try {
453+
runBlocking {
454+
shutdown()
455+
}
456+
} catch (_ : InterruptedException) {
457+
454458
}
455459
}
456460
})
@@ -509,4 +513,4 @@ public interface MiraiConsoleImplementation : CoroutineScope {
509513
}
510514
}
511515
}
512-
}
516+
}

0 commit comments

Comments
 (0)