Browse Source

Avoid NullPointerException when jms destination is not available (#11570)

Lauri Tulmin 9 months ago
parent
commit
55e723e810

+ 7 - 5
instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessageWithDestination.java

@@ -31,11 +31,13 @@ public abstract class MessageWithDestination {
       jmsDestination = fallbackDestination;
     }
 
-    if (jmsDestination.isQueue()) {
-      return createMessageWithQueue(message, jmsDestination);
-    }
-    if (jmsDestination.isTopic()) {
-      return createMessageWithTopic(message, jmsDestination);
+    if (jmsDestination != null) {
+      if (jmsDestination.isQueue()) {
+        return createMessageWithQueue(message, jmsDestination);
+      }
+      if (jmsDestination.isTopic()) {
+        return createMessageWithTopic(message, jmsDestination);
+      }
     }
     return new AutoValue_MessageWithDestination(
         message, "unknown", /* isTemporaryDestination= */ false);