From 097b9c30754c77858aff684b113ed305cec7cf57 Mon Sep 17 00:00:00 2001 From: slyouts Date: Wed, 15 May 2019 15:19:25 -0400 Subject: [PATCH] NIFI-6022 Added try/catch to protect against secondary exception in a primary exception catch clause NIFI-6022 mods per PR review NIFI-6022 mods per PR review This closes #3476. Signed-off-by: Koji Kawamura --- .../java/org/apache/nifi/jms/processors/JMSConsumer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java index a2c73b4e3b..3c16ee26eb 100644 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java @@ -126,7 +126,12 @@ final class JMSConsumer extends JMSWorker { // We need to call recover to ensure that in the event of // abrupt end or exception the current session will stop message // delivery and restart with the oldest unacknowledged message - session.recover(); + try { + session.recover(); + } catch (Exception e1) { + // likely the session is closed...need to catch this so that the root cause of failure is propagated + processLog.debug("Failed to recover JMS session while handling initial error. The recover error is: ", e1); + } throw e; } finally { JmsUtils.closeMessageConsumer(msgConsumer);