Skip to content

Commit ba842f2

Browse files
committed
Don't use shutdown() in shutdownNow()
Calling scheduleShutdownSignal more than once is not great
1 parent b3133de commit ba842f2

File tree

1 file changed

+5
-1
lines changed
  • src/main/kotlin/io/github/freya022/botcommands/internal/core

1 file changed

+5
-1
lines changed

src/main/kotlin/io/github/freya022/botcommands/internal/core/BContextImpl.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ internal class BContextImpl internal constructor(
179179
}
180180

181181
override fun shutdownNow() {
182-
shutdown()
182+
// Do not call shutdown(), more precisely do not call scheduleShutdownSignal() twice
183+
if (status == Status.SHUTTING_DOWN || status == Status.SHUTDOWN) return
184+
removeShutdownHook()
185+
186+
runBlocking { setStatus(Status.SHUTTING_DOWN) }
183187

184188
scheduleShutdownSignal(afterShutdownSignal = {
185189
shutdownEventManagerScope(now = true)

0 commit comments

Comments
 (0)