From 8f382caac624f11430fcdab75ed0526d95e71422 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 19 Mar 2014 20:24:06 +0100 Subject: [PATCH] [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. --- .../agent/impl/ComponentContainerImpl.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/li/strolch/agent/impl/ComponentContainerImpl.java b/src/main/java/li/strolch/agent/impl/ComponentContainerImpl.java index a60b0d0e7..7342a0e8b 100644 --- a/src/main/java/li/strolch/agent/impl/ComponentContainerImpl.java +++ b/src/main/java/li/strolch/agent/impl/ComponentContainerImpl.java @@ -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