Skip to content

Commit

Permalink
Clarify command timeout warning msg
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko authored and fonnymunkey committed May 6, 2024
1 parent 121e604 commit bdef6b5
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,12 @@ public void executeCommand(CommandSender sender, String[] args) {
// schedule a task to detect timeouts
this.plugin.executeAsync(() -> {
timeoutThread.set(Thread.currentThread());
int warningIntervalSeconds = 5;

try {
for (int i = 1; i <= 3; i++) {
try {
Thread.sleep(5000);
Thread.sleep(warningIntervalSeconds * 1000);
} catch (InterruptedException e) {
// ignore
}
Expand All @@ -382,15 +384,17 @@ public void executeCommand(CommandSender sender, String[] args) {
Thread executor = executorThread.get();
if (executor == null) {
getPlugin().log(Level.WARNING, "A command execution has not completed after " +
(i * 5) + " seconds but there is no executor present. Perhaps the executor shutdown?");
(i * warningIntervalSeconds) + " seconds but there is no executor present. Perhaps the executor shutdown?");
getPlugin().log(Level.WARNING, "If the command subsequently completes without any errors, this warning should be ignored. :)");

} else {
String stackTrace = Arrays.stream(executor.getStackTrace())
.map(el -> " " + el.toString())
.collect(Collectors.joining("\n"));

getPlugin().log(Level.WARNING, "A command execution has not completed after " +
(i * 5) + " seconds, it might be stuck. Trace: \n" + stackTrace);
(i * warningIntervalSeconds) + " seconds, it *might* be stuck. Trace: \n" + stackTrace);
getPlugin().log(Level.WARNING, "If the command subsequently completes without any errors, this warning should be ignored. :)");
}
}
} finally {
Expand Down

0 comments on commit bdef6b5

Please sign in to comment.