Skip to content

Commit

Permalink
port InterruptedException fix to jda5
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Jul 7, 2024
1 parent e95b4bf commit ca9a02e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private Message updateMessage() throws IllegalStateException {
}
} catch (InterruptedException e) {
JDA.Status status = channel.getJDA().getStatus();
if (status == JDA.Status.SHUTTING_DOWN || status == JDA.Status.SHUTDOWN) {
if (executor == null || executor.isShutdown() || status == JDA.Status.SHUTTING_DOWN || status == JDA.Status.SHUTDOWN) {
// ignored, no-op
return currentMessage;
} else {
Expand All @@ -264,7 +264,7 @@ private Message updateMessage() throws IllegalStateException {
throw new RuntimeException(e);
} catch (InterruptedException e) {
JDA.Status status = channel.getJDA().getStatus();
if (status == JDA.Status.SHUTTING_DOWN || status == JDA.Status.SHUTDOWN) {
if (executor == null || executor.isShutdown() || status == JDA.Status.SHUTTING_DOWN || status == JDA.Status.SHUTDOWN) {
// ignored, no-op
return currentMessage;
} else {
Expand Down Expand Up @@ -302,11 +302,16 @@ public void recreateChannel(@Nullable String reason) {
*/
public void shutdownExecutor() {
if (scheduledFuture != null) {
scheduledFuture.cancel(true);
scheduledFuture.cancel(false);
scheduledFuture = null;
}
if (executor != null) {
executor.shutdown();
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
// ignore, it's fine if the last tidbit of console output doesn't get sent
}
executor = null;
}
}
Expand Down

0 comments on commit ca9a02e

Please sign in to comment.