From f0074278a2c3a8d81d14d5e89a058c293a19a948 Mon Sep 17 00:00:00 2001 From: cfredri4 Date: Tue, 17 Dec 2024 15:13:31 +0100 Subject: [PATCH] Handle RuntimeException when getting/setting JMS headers Currently JMSException is handled when getting/setting JMS headers. Some JMS providers will throw RuntimeException instead of JMSException when failing to get/set JMS headers. This change adds so that RuntimeException is also handled. --- .../jakarta9/instrument/jms/JmsProcessObservationContext.java | 2 +- .../jakarta9/instrument/jms/JmsPublishObservationContext.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java index 4d8d29a892..bd93abc322 100644 --- a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java +++ b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java @@ -38,7 +38,7 @@ public JmsProcessObservationContext(Message receivedMessage) { try { return message.getStringProperty(key); } - catch (JMSException exc) { + catch (JMSException | RuntimeException exc) { return null; } }); diff --git a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java index f16d2154d9..545145e052 100644 --- a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java +++ b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java @@ -40,7 +40,7 @@ public JmsPublishObservationContext(@Nullable Message sendMessage) { message.setStringProperty(key, value); } } - catch (JMSException exc) { + catch (JMSException | RuntimeException exc) { // ignore } });