From 676a443cf2d52925aa4374339f588e737f720039 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 4 Dec 2019 21:20:09 -0500 Subject: [PATCH] NPEs --- .../java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java index 85f6373e90f..418e9b8d050 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java @@ -76,6 +76,9 @@ public abstract class BaseHapiScheduler implements IHapiScheduler { @Override public void start() { + if (myScheduler == null) { + throw new ConfigurationException("Attempt to start uninitialized scheduler"); + } try { ourLog.info("Starting scheduler {}", getThreadPrefix()); myScheduler.start(); @@ -87,6 +90,9 @@ public abstract class BaseHapiScheduler implements IHapiScheduler { @Override public void shutdown() { + if (myScheduler == null) { + return; + } try { myScheduler.shutdown(true); } catch (SchedulerException e) { @@ -98,7 +104,7 @@ public abstract class BaseHapiScheduler implements IHapiScheduler { @Override public boolean isStarted() { try { - return myScheduler.isStarted(); + return myScheduler != null && myScheduler.isStarted(); } catch (SchedulerException e) { ourLog.error("Failed to determine scheduler status", e); return false;