From ba5425c9582ed7cec4b70f312a6b461cef4360b3 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 21 Dec 2019 15:56:09 +0000 Subject: [PATCH] extra check for stopped cache client --- .../groovy/com/muwire/core/hostcache/CacheClient.groovy | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/groovy/com/muwire/core/hostcache/CacheClient.groovy b/core/src/main/groovy/com/muwire/core/hostcache/CacheClient.groovy index 0f605aa2..673232dc 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/CacheClient.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/CacheClient.groovy @@ -1,5 +1,7 @@ package com.muwire.core.hostcache +import java.util.concurrent.atomic.AtomicBoolean + import com.muwire.core.EventBus import com.muwire.core.MuWireSettings import com.muwire.core.connection.ConnectionManager @@ -27,6 +29,7 @@ class CacheClient { final long interval final MuWireSettings settings final Timer timer + private final AtomicBoolean stopped = new AtomicBoolean(); public CacheClient(EventBus eventBus, HostCache cache, ConnectionManager manager, I2PSession session, @@ -47,9 +50,12 @@ class CacheClient { void stop() { timer.cancel() + stopped.set(true) } private void queryIfNeeded() { + if (stopped.get()) + return if (!manager.getConnections().isEmpty()) return if (!cache.getHosts(1).isEmpty())