ServiceRegistration registration = services.remove(pid);
if (registration == null) {
logger.debug("Cache service with pid '{}' was never registered and can therefore not be deleted", pid);
return;
}
CacheService cache = (CacheService) bundleCtx.getService(registration.getReference());
try {
registration.unregister();
} catch (IllegalStateException e) {
// Never mind, the service has been unregistered already
} catch (Throwable t) {
logger.error("Unregistering cache service failed: {}", t.getMessage());
}
cache.shutdown();
}