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 // If not found in connection we look up if we got the Capabilities set from any of the
// reported or persisted peers // reported or persisted peers
Set<Peer> persistedAndReported = new HashSet<>(getPersistedPeers()); Set<Peer> persistedAndReported = new HashSet<>(getPersistedPeers());
persistedAndReported.addAll(getReportedPeers()); synchronized (reportedPeers) {
persistedAndReported.addAll(reportedPeers);
}
Optional<Peer> candidate = persistedAndReported.stream() Optional<Peer> candidate = persistedAndReported.stream()
.filter(peer -> peer.getNodeAddress().equals(peersNodeAddress)) .filter(peer -> peer.getNodeAddress().equals(peersNodeAddress))
.filter(peer -> !peer.getCapabilities().isEmpty()) .filter(peer -> !peer.getCapabilities().isEmpty())