Source:
<code>public void init() { final StatusTransitioner.Transition st = statusTransitioner.init(); if (serviceLocator.getService(CacheManagerProviderService.class) == null) { this.serviceLocator.addService(new DefaultCacheManagerProviderService(this)); } try { for (ServiceCreationConfiguration<? extends Service> serviceConfig : configuration.getServiceCreationConfigurations()) { Service service = serviceLocator.getOrCreateServiceFor(serviceConfig); if (service == null) { throw new IllegalArgumentException("Couldn't resolve Service " + serviceConfig.getServiceType().getName()); } } serviceLocator.loadDependenciesOf(ServiceDeps.class); try { serviceLocator.startAllServices(); } catch (Exception e) { throw st.failed(e); } statisticsManager.root(this); Deque<String> initiatedCaches = new ArrayDeque<String>(); try { for (Entry<String, CacheConfiguration<?, ?>> cacheConfigurationEntry : configuration.getCacheConfigurations() .entrySet()) { final String alias = cacheConfigurationEntry.getKey(); createCache(alias, cacheConfigurationEntry.getValue(), false); initiatedCaches.push(alias); } } catch (RuntimeException e) { while (!initiatedCaches.isEmpty()) { String toBeClosed = initiatedCaches.pop(); try { removeCache(toBeClosed, false); } catch (Exception exceptionClosingCache) { LOGGER.error("Cache '{}' could not be removed due to ", toBeClosed, exceptionClosingCache); } } <START> serviceLocator.stopAllServices(); <END> throw e; } } catch (Exception e) { throw st.failed(e); } st.succeeded(); }</code><technical_language>If this throws, shadow original exception. a consequence fixing problem harder</technical_language>

Target:
public void init() { final StatusTransitioner.Transition st = statusTransitioner.init(); if (serviceLocator.getService(CacheManagerProviderService.class) == null) { this.serviceLocator.addService(new DefaultCacheManagerProviderService(this)); } try { for (ServiceCreationConfiguration<? extends Service> serviceConfig : configuration.getServiceCreationConfigurations()) { Service service = serviceLocator.getOrCreateServiceFor(serviceConfig); if (service == null) { throw new IllegalArgumentException("Couldn't resolve Service " + serviceConfig.getServiceType().getName()); } } serviceLocator.loadDependenciesOf(ServiceDeps.class); try { serviceLocator.startAllServices(); } catch (Exception e) { throw st.failed(e); } statisticsManager.root(this); Deque<String> initiatedCaches = new ArrayDeque<String>(); try { for (Entry<String, CacheConfiguration<?, ?>> cacheConfigurationEntry : configuration.getCacheConfigurations() .entrySet()) { final String alias = cacheConfigurationEntry.getKey(); createCache(alias, cacheConfigurationEntry.getValue(), false); initiatedCaches.push(alias); } } catch (RuntimeException e) { while (!initiatedCaches.isEmpty()) { String toBeClosed = initiatedCaches.pop(); try { removeCache(toBeClosed, false); } catch (Exception exceptionClosingCache) { LOGGER.error("Cache '{}' could not be removed due to ", toBeClosed, exceptionClosingCache); } } try { serviceLocator.stopAllServices(); } catch (Exception exceptionStoppingServices) { LOGGER.error("Stopping services failed due to ", exceptionStoppingServices); } throw e; } } catch (Exception e) { throw st.failed(e); } st.succeeded(); }