Fix grizzly server null check

This commit is contained in:
Andrea Cavalli 2024-03-02 22:41:11 +01:00
parent dee9941a1f
commit 6e3c41f7c4

View File

@ -91,13 +91,15 @@ public class DefaultWebhook implements Webhook, Closeable {
@Override
public void close() throws IOException {
try {
grizzlyServer.shutdown(1, TimeUnit.MINUTES).get();
} catch (ExecutionException ex) {
throw new IOException("Failed to stop grizzly server", ex.getCause());
} catch (InterruptedException e) {
// timeout
if (grizzlyServer != null) {
try {
grizzlyServer.shutdown(1, TimeUnit.MINUTES).get();
} catch (ExecutionException ex) {
throw new IOException("Failed to stop grizzly server", ex.getCause());
} catch (InterruptedException e) {
// timeout
}
grizzlyServer.shutdownNow();
}
grizzlyServer.shutdownNow();
}
}