[Bugfix] fixed problem stopping component that throws exception

Now we are sure that if a component fails to stop or destroy, we catch
the situation and carry on stopping the others. This handling is not
done when starting, as there we don't want to finish starting the agent
if something goes wrong.
This commit is contained in:
Robert von Burg 2014-03-19 20:24:06 +01:00
parent 2894b5b157
commit 8f382caac6
1 changed files with 14 additions and 2 deletions

View File

@ -199,7 +199,13 @@ public class ComponentContainerImpl implements ComponentContainer {
String msg = "Stopping component {0}..."; //$NON-NLS-1$
String componentName = component.getName();
logger.info(MessageFormat.format(msg, componentName));
component.stop();
try {
component.stop();
} catch (Exception e) {
msg = "Failed to stop component {0} due to {1}";
msg = MessageFormat.format(msg, componentName, e.getMessage());
logger.error(msg, e);
}
}
// Stop direct upstream components
@ -219,7 +225,13 @@ public class ComponentContainerImpl implements ComponentContainer {
String msg = "Destroying component {0}..."; //$NON-NLS-1$
String componentName = component.getName();
logger.info(MessageFormat.format(msg, componentName));
component.destroy();
try {
component.destroy();
} catch (Exception e) {
msg = "Failed to destroy component {0} due to {1}";
msg = MessageFormat.format(msg, componentName, e.getMessage());
logger.error(msg, e);
}
}
// Destroy direct upstream components