From c7a0e59919cafc56539865fcfaea9e8d9978091b Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 11 May 2020 21:15:42 +0100 Subject: [PATCH] Catch RejectedExecutionException in BufferedRequest (#2289) --- .../bukkit/listeners/BukkitCommandListUpdater.java | 4 ++++ .../me/lucko/luckperms/common/cache/BufferedRequest.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitCommandListUpdater.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitCommandListUpdater.java index aa9a0f7ec..6f686ad19 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitCommandListUpdater.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitCommandListUpdater.java @@ -63,6 +63,10 @@ public class BukkitCommandListUpdater { // Called when a user's data is recalculated. public void onUserDataRecalculate(UserDataRecalculateEvent e) { + if (this.plugin.getBootstrap().isServerStopping()) { + return; + } + UUID uniqueId = e.getUser().getUniqueId(); if (!this.plugin.getBootstrap().isPlayerOnline(uniqueId)) { return; diff --git a/common/src/main/java/me/lucko/luckperms/common/cache/BufferedRequest.java b/common/src/main/java/me/lucko/luckperms/common/cache/BufferedRequest.java index fc7a53838..93d938843 100644 --- a/common/src/main/java/me/lucko/luckperms/common/cache/BufferedRequest.java +++ b/common/src/main/java/me/lucko/luckperms/common/cache/BufferedRequest.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter; import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; @@ -139,7 +140,12 @@ public abstract class BufferedRequest { private void scheduleTask() { this.boundTask = new CompletionTask(); - this.scheduledTask = this.schedulerAdapter.asyncLater(this.boundTask, this.delay, this.unit); + try { + this.scheduledTask = this.schedulerAdapter.asyncLater(this.boundTask, this.delay, this.unit); + } catch (RejectedExecutionException e) { + // If we can't schedule the completion in the future, just do it now. + this.boundTask.run(); + } } CompletableFuture getFuture() {