fix concurrent modification exception in peer manager

This commit is contained in:
woodser 2024-01-04 20:10:25 -05:00
parent 497de47965
commit 59b2a1121b

View File

@ -774,7 +774,9 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
// If not found in connection we look up if we got the Capabilities set from any of the
// reported or persisted peers
Set<Peer> persistedAndReported = new HashSet<>(getPersistedPeers());
persistedAndReported.addAll(getReportedPeers());
synchronized (reportedPeers) {
persistedAndReported.addAll(reportedPeers);
}
Optional<Peer> candidate = persistedAndReported.stream()
.filter(peer -> peer.getNodeAddress().equals(peersNodeAddress))
.filter(peer -> !peer.getCapabilities().isEmpty())