Skip to content

Commit

Permalink
fix: add try-finally to server stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Mar 8, 2024
1 parent 2526e8b commit 08b1672
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Allay-Server/src/main/java/org/allaymc/server/AllayServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,15 @@ public void shutdown() {
scoreboardService.save();
// Start a thread to handle server shutdown
Thread.ofPlatform().start(() -> {
kickAllPlayersAndBlock();
isRunning.compareAndSet(true, false);
worldPool.close();
playerStorage.close();
virtualThreadPool.shutdownNow();
computeThreadPool.shutdownNow();
try {
kickAllPlayersAndBlock();
} finally {
isRunning.compareAndSet(true, false);
worldPool.close();
playerStorage.close();
virtualThreadPool.shutdownNow();
computeThreadPool.shutdownNow();
}
System.exit(0);
});
}
Expand Down

0 comments on commit 08b1672

Please sign in to comment.