// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.identity;

import com.yahoo.vespa.athenz.api.AthenzService;

import javax.net.ssl.SSLContext;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;

/**
 * A helper class managing {@link ServiceIdentityProvider.Listener} instances for implementations of {@link ServiceIdentityProvider}.
 *
 * @author bjorncs
 */
public class ServiceIdentityProviderListenerHelper {

    private final Set<ServiceIdentityProvider.Listener> listeners = new ConcurrentSkipListSet<>();
    private final AthenzService identity;

    public ServiceIdentityProviderListenerHelper(AthenzService identity) {
        this.identity = identity;
    }

    public void addIdentityListener(ServiceIdentityProvider.Listener listener) {
        listeners.add(listener);
    }

    public void removeIdentityListener(ServiceIdentityProvider.Listener listener) {
        listeners.remove(listener);
    }

    public void onCredentialsUpdate(SSLContext sslContext) {
        listeners.forEach(l -> l.onCredentialsUpdate(sslContext, identity));
    }

    public void clearListeners() {
        listeners.clear();
    }

}

@@ -289,32 +289,30 @@
 rrent.Co
-ncurrentSkipList
+pyOnWriteArray
 Set;%0A%0A/*
@@ -605,24 +605,22 @@
 w Co
-ncurrentSkipList
+pyOnWriteArray
 Set%3C

Use ConcurrentCopyOnWriteArraySet -- could alternatively provide a Comparator