Skip to content

Commit 2556768

Browse files
committed
fix swarm test (ignore nodes with multiaddresses we can't parse)
1 parent 3b502ac commit 2556768

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/io/ipfs/api/IPFS.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,14 @@ public List<MultiAddress> rm(MultiAddress addr, boolean all) throws IOException
459459
public class Swarm {
460460
public List<Peer> peers() throws IOException {
461461
Map m = retrieveMap("swarm/peers?stream-channels=true");
462-
return ((List<Object>)m.get("Peers")).stream().map(Peer::fromJSON).collect(Collectors.toList());
462+
return ((List<Object>)m.get("Peers")).stream()
463+
.flatMap(json -> {
464+
try {
465+
return Stream.of(Peer.fromJSON(json));
466+
} catch (Exception e) {
467+
return Stream.empty();
468+
}
469+
}).collect(Collectors.toList());
463470
}
464471

465472
public Map addrs() throws IOException {

0 commit comments

Comments
 (0)