From a5fb0be274da95fefe6e64ce765c13684621e900 Mon Sep 17 00:00:00 2001 From: catbref Date: Tue, 15 Mar 2022 20:59:56 +0000 Subject: [PATCH] Fix Network.disconnectPeer(PeerAddress) to prevent removeIf() on UnmodifiableList throwing UnsupportedOperationException --- src/main/java/org/qortal/network/Network.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/qortal/network/Network.java b/src/main/java/org/qortal/network/Network.java index 20931483..20aa10d1 100644 --- a/src/main/java/org/qortal/network/Network.java +++ b/src/main/java/org/qortal/network/Network.java @@ -1303,8 +1303,9 @@ public class Network { try { InetSocketAddress knownAddress = peerAddress.toSocketAddress(); - List peers = this.getImmutableConnectedPeers(); - peers.removeIf(peer -> !Peer.addressEquals(knownAddress, peer.getResolvedAddress())); + List peers = this.getImmutableConnectedPeers().stream() + .filter(peer -> Peer.addressEquals(knownAddress, peer.getResolvedAddress())) + .collect(Collectors.toList()); for (Peer peer : peers) { peer.disconnect("to be forgotten");