@Override
    protected Collection<Address> getPossibleAddresses() {
        Iterable<DiscoveryNode> discoveredNodes = checkNotNull(discoveryService.discoverNodes(),
                "Discovered nodes cannot be null!");

        MemberImpl localMember = node.nodeEngine.getLocalMember();
        Set<Address> localAddresses = node.getLocalAddressRegistry().getLocalAddresses();

        Collection<Address> possibleMembers = new ArrayList<>();
        for (DiscoveryNode discoveryNode : discoveredNodes) {
            Address discoveredAddress = usePublicAddress ? discoveryNode.getPublicAddress() : discoveryNode.getPrivateAddress();
            if (localAddresses.contains(discoveredAddress)) {
                if (!usePublicAddress && discoveryNode.getPublicAddress() != null) {
                    // enrich member with client public address
                    localMember.getAddressMap().put(EndpointQualifier.resolve(ProtocolType.CLIENT, "public"),
                            publicAddress(localMember, discoveryNode));
                }
                continue;
            }
            possibleMembers.add(discoveredAddress);
        }
        return possibleMembers;
    }
@Test
    public void test_DiscoveryJoiner_enriches_member_with_public_address_when_advanced_network_used()
            throws UnknownHostException {
        DiscoveryJoiner joiner = new DiscoveryJoiner(getNode(hz), service, false);
        doReturn(discoveryNodes).when(service).discoverNodes();
        // the CLIENT protocol server socket listens on port 5703
        // but is mapped to public address 127.0.0.2:6701
        getNode(hz).getLocalMember().getAddressMap().put(EndpointQualifier.CLIENT, new Address("127.0.0.1", 5703));
        Collection<Address> addresses = joiner.getPossibleAddresses();
        String expected;
        if (discoveryBehaviourFallbackEnabled) {
            expected = "[127.0.0.2]:5703";
        } else {
            expected = "[127.0.0.2]:6701";
        }
        assertEquals(expected, getNode(hz).getLocalMember().getAddressMap()
                .get(CLIENT_PUBLIC_ENDPOINT_QUALIFIER).toString());
    }