From 46e5cf23f80faaf1936c1f89c33ac9812b39af0a Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Wed, 17 Jun 2020 18:01:38 -0500 Subject: [PATCH] Add null check for safety --- src/main/java/mdnet/base/MangaDexClient.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/mdnet/base/MangaDexClient.java b/src/main/java/mdnet/base/MangaDexClient.java index 68acd64..8b16b12 100644 --- a/src/main/java/mdnet/base/MangaDexClient.java +++ b/src/main/java/mdnet/base/MangaDexClient.java @@ -119,7 +119,7 @@ public class MangaDexClient { } gracefulCounter++; } else if (gracefulCounter > 0) { - if (!isHandled.get() || gracefulCounter == 4) { + if (!isHandled.get() || gracefulCounter == 4 || engine == null) { if (LOGGER.isInfoEnabled()) { if (!isHandled.get()) { LOGGER.info("No requests received, shutting down"); @@ -128,7 +128,9 @@ public class MangaDexClient { } } - stopServer(); + if (engine != null) { + stopServer(); + } if (gracefulAction != null) { gracefulAction.run(); }