class ConsulServiceDiscovery extends AbstractServiceDiscovery implements EventListener<ServiceInstancesChangedEvent> {

    @Override
    public List<ServiceInstance> getInstances(String serviceName) throws NullPointerException {
        Response<List<HealthService>> response = getHealthServices(serviceName, -1, buildWatchTimeout());
        Long consulIndex = response.getConsulIndex();

        ConsulNotifier notifier = notifiers.get(serviceName);
        if (notifier == null) {
            notifier = new ConsulNotifier(serviceName, consulIndex);
            notifiers.put(serviceName, notifier);
        }
        return convert(response.getValue());
    }

}