Check if disposable is available
@@ -57,8 +57,11 @@ public class BuildClusterHealthChecker implements LeaderLatchListener, Managed {
public void stop() throws Exception {
running.compareAndSet(true, false);
LOG.info("We have been stopped. Stopping build clusters health checks");
+ Disposable clusterHealthCheckObserver = clusterHealthObserver.get();
+ if (clusterHealthCheckObserver != null) {
clusterHealthObserver.get().dispose();
}
+ }
@Override
public void isLeader() {
