prevent exception on shutodwn reported in GitHub issue #157

dbus-notify
Zlatin Balevsky 2022-06-24 23:33:13 +01:00
parent e690a2f124
commit b04179631c
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 12 additions and 4 deletions

View File

@ -29,6 +29,7 @@ class H2HostCache extends HostCache {
private final Map<Destination, HostMCProfile> profiles = new HashMap<>()
private final Timer timer
private boolean closed
private Collection<Destination> toVerify = new LinkedHashSet<>()
@ -302,6 +303,7 @@ class H2HostCache extends HostCache {
public synchronized void stop() {
try {timer.cancel()} catch (Exception ignore) {}
sql?.close()
closed = true
}
@Override
public synchronized void load() {
@ -346,14 +348,20 @@ class H2HostCache extends HostCache {
log.fine("loaded ${allHosts.size()} hosts from db")
timer.schedule({
recycleSQL()
purgeHopeless()
verifyHosts()
recordConnectionCount()
houseKeep()
} as TimerTask, 60000, 60000)
loaded = true
}
private synchronized void houseKeep() {
if (closed)
return
recycleSQL()
purgeHopeless()
verifyHosts()
recordConnectionCount()
}
private synchronized void verifyHosts() {
log.fine("starting verification")
final long now = System.currentTimeMillis()