use of com.netflix.eventbus.spi.InvalidSubscriberException in project eureka by Netflix.
the class DiscoveryClientResource method awaitCacheUpdate.
public boolean awaitCacheUpdate(long timeout, TimeUnit unit) throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
Object eventListener = new Object() {
@Subscribe
public void consume(CacheRefreshedEvent event) {
latch.countDown();
}
};
try {
getEventBus().registerSubscriber(eventListener);
} catch (InvalidSubscriberException e) {
throw new IllegalStateException("Unexpected error during subscriber registration", e);
}
try {
return latch.await(timeout, unit);
} finally {
getEventBus().unregisterSubscriber(eventListener);
}
}
Aggregations