From 38ea8d1df43d43f55a8d0940a1fa0cbefda6bc56 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 26 Feb 2016 12:25:16 -0500 Subject: [PATCH] Remove exception firewall from AutopsyEventPublisher --- .../autopsy/events/AutopsyEventPublisher.java | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/events/AutopsyEventPublisher.java b/Core/src/org/sleuthkit/autopsy/events/AutopsyEventPublisher.java index 9ed6e87d4f..5fe17a57ef 100644 --- a/Core/src/org/sleuthkit/autopsy/events/AutopsyEventPublisher.java +++ b/Core/src/org/sleuthkit/autopsy/events/AutopsyEventPublisher.java @@ -86,24 +86,8 @@ public final class AutopsyEventPublisher { * events from other Autopsy nodes. */ public void closeRemoteEventChannel() { - currentChannelName = null; stopRemotePublisher(); - } - - /** - * Stops remote event publisher, causing it to disconnect from the message - * service. As opposed to closeRemoteEventChannel(), this method allows for - * the current remote event channel to be re-opened later. - */ - private void stopRemotePublisher() { - if (null != remotePublisher) { - try { - remotePublisher.stop(); - } catch (JMSException ex) { - logger.log(Level.SEVERE, "Error closing remote event channel", ex); //NON-NLS - } - remotePublisher = null; - } + currentChannelName = null; } /** @@ -171,9 +155,6 @@ public final class AutopsyEventPublisher { * @param event The event to publish. */ public void publishRemotely(AutopsyEvent event) { - /* - * This is a no-op if a remote channel has not been opened. - */ if (null != currentChannelName) { boolean published = false; int tryCount = 1; @@ -185,19 +166,28 @@ public final class AutopsyEventPublisher { } remotePublisher.publish(event); published = true; - } catch (JMSException ex) { + } catch (AutopsyEventException | JMSException ex) { logger.log(Level.SEVERE, String.format("Failed to publish %s using channel %s (tryCount = %s)", event.getPropertyName(), currentChannelName, tryCount), ex); //NON-NLS stopRemotePublisher(); ++tryCount; - } catch (AutopsyEventException ex) { - logger.log(Level.SEVERE, String.format("Failed to reopen channel %s to publish %s event (tryCount = %s)", currentChannelName, event.getPropertyName(), tryCount), ex); //NON-NLS - ++tryCount; - } catch (Exception ex) { - logger.log(Level.SEVERE, String.format("Unexpected exception! Failed to to publish %s event on channel %s (tryCount = %s)", event.getPropertyName(), currentChannelName, tryCount), ex); //NON-NLS - ++tryCount; } } - } + } + } + + /** + * Stops the remote event publisher, but does not reset the current channel + * name. + */ + private void stopRemotePublisher() { + if (null != remotePublisher) { + try { + remotePublisher.stop(); + } catch (JMSException ex) { + logger.log(Level.SEVERE, String.format("Error closing remote event publisher for channel %s", currentChannelName), ex); //NON-NLS + } + remotePublisher = null; + } } }