for (ServiceWithDependency sd : services.values()) {
serviceList.add(sd.service);
}
Exception firstException = null;
for (int i = services.size() - 1; i >= 0; i--) {
Service service = serviceList.get(i);
if (LOG.isDebugEnabled()) {
LOG.debug("Stopping service : " + service);
}
Exception ex = ServiceOperations.stopQuietly(LOG, service);
if (ex != null && firstException == null) {
LOG.warn("Failed to stop service, name=" + service.getName(), ex);
firstException = ex;
}
}
//after stopping all services, rethrow the first exception raised
if (firstException != null) {