mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Fixed factory method for NodeAddresses in case of empty string
This commit is contained in:
parent
6f10d7d75e
commit
5bb91a3fd3
2 changed files with 12 additions and 0 deletions
|
@ -21,6 +21,7 @@ import io.bisq.network.p2p.NodeAddress;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collector;
|
||||
|
@ -28,6 +29,10 @@ import java.util.stream.Collectors;
|
|||
|
||||
class NodeAddresses extends ImmutableSetDecorator<NodeAddress> {
|
||||
static NodeAddresses fromString(String seedNodes) {
|
||||
if (seedNodes.isEmpty()) {
|
||||
return new NodeAddresses(Collections.emptySet());
|
||||
}
|
||||
|
||||
String trimmed = StringUtils.deleteWhitespace(seedNodes);
|
||||
String[] nodes = trimmed.split(",");
|
||||
return Arrays.stream(nodes)
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class NodeAddressesTest {
|
||||
@Before
|
||||
|
@ -74,4 +75,10 @@ public class NodeAddressesTest {
|
|||
NodeAddresses actual = NodeAddresses.fromString("192.168.0.1:1111, 192.168.0.2:2222");
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromEmptyString() {
|
||||
NodeAddresses nodeAddresses = NodeAddresses.fromString("");
|
||||
assertTrue(nodeAddresses.isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue