diff --git a/instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessageWithDestination.java b/instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessageWithDestination.java index d394a77427bd..1c55fc693e17 100644 --- a/instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessageWithDestination.java +++ b/instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessageWithDestination.java @@ -31,11 +31,13 @@ public static MessageWithDestination create( 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);