fix autocloseable executors
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-09 11:30:59 +01:00
parent f523e6cd92
commit 04d93dd7a5
3 changed files with 12 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.util;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Deprecated(since = "0.5.16", forRemoval = true)
@@ -49,7 +50,9 @@ public class Logger<T>
{
// create a new scheduled executor with an anonymous runnable...
//... after waiting <delay> seconds.
Executors.newSingleThreadScheduledExecutor().schedule(() -> log(message), delay, TimeUnit.SECONDS);
try (ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor()) {
executor.schedule(() -> log(message), delay, TimeUnit.SECONDS);
}
}