@Override
    public Collection<User> findUsers( Set<String> fields, String query ) throws UnsupportedOperationException
    {
        final AtomicLong supportSearch = new AtomicLong(getUserProviders().size());
        final Set<User> result = getUserProviders().parallelStream()
            .map(provider -> {
                try {
                    // Use only those fields that are supported by the provider.
                    final Set<String> supportedFields = new HashSet<>(fields);
                    supportedFields.retainAll(provider.getSearchFields());
                    return provider.findUsers(supportedFields, query);
                } catch (UnsupportedOperationException uoe) {
                    Log.warn("UserProvider.findUsers is not supported by this UserProvider: {}. Its users are not returned as part of search queries.", provider.getClass().getName());
                    supportSearch.decrementAndGet();
                    return new HashSet<User>();
                }
            })
            .flatMap(Collection::stream)
            .collect(Collectors.toSet());

        if (supportSearch.longValue() == 0) {
            throw new UnsupportedOperationException("None of the backing providers support this operation.");
        }
        return result;
    }
Searches for users based on a set of fields and a query string. The fields must  be taken from the values
returned by {@link #getSearchFields()}. The query can  include wildcards. For example, a search on the field
"Name" with a query of "Ma*"  might return user's with the name "Matt", "Martha" and "Madeline".

This method throws an UnsupportedOperationException when none of the backing providers support search.

When fields are provided that are not supported by a particular provider, those fields are ignored by that
provider (but can still be used by other providers).

@param fields the fields to search on.
@param query  the query string.
@return a Collection of users that match the search.
@throws UnsupportedOperationException When none of the providers support search.
xmppserver/src/main/java/org/jivesoftware/openfire/user/UserMultiProvider.java