do not create new objects because that clears the successes

This commit is contained in:
Zlatin Balevsky
2019-06-05 21:07:23 +01:00
parent 6782849a12
commit 94f6de6bea
2 changed files with 9 additions and 1 deletions

View File

@@ -30,4 +30,8 @@ class Host {
synchronized boolean hasSucceeded() { synchronized boolean hasSucceeded() {
successes > 0 successes > 0
} }
synchronized void clearFailures() {
failures = null
}
} }

View File

@@ -46,8 +46,12 @@ class HostCache extends Service {
void onHostDiscoveredEvent(HostDiscoveredEvent e) { void onHostDiscoveredEvent(HostDiscoveredEvent e) {
if (myself == e.destination) if (myself == e.destination)
return return
if (hosts.containsKey(e.destination) && !e.fromHostcache) if (hosts.containsKey(e.destination)) {
if (!e.fromHostcache)
return return
hosts.get(e.destination).clearFailures()
return
}
Host host = new Host(e.destination) Host host = new Host(e.destination)
if (allowHost(host)) { if (allowHost(host)) {
hosts.put(e.destination, host) hosts.put(e.destination, host)