Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle RuntimeException when getting/setting JMS headers #5746

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.micrometer.jakarta9.instrument.jms;

import io.micrometer.common.util.internal.logging.WarnThenDebugLogger;
import io.micrometer.observation.transport.ReceiverContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;

/**
Expand All @@ -33,12 +33,15 @@
*/
public class JmsProcessObservationContext extends ReceiverContext<Message> {

private static final WarnThenDebugLogger logger = new WarnThenDebugLogger(JmsProcessObservationContext.class);

public JmsProcessObservationContext(Message receivedMessage) {
super((message, key) -> {
try {
return message.getStringProperty(key);
}
catch (JMSException exc) {
catch (Exception exc) {
logger.log("Failed to get message property.", exc);
return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package io.micrometer.jakarta9.instrument.jms;

import io.micrometer.common.lang.Nullable;
import io.micrometer.common.util.internal.logging.WarnThenDebugLogger;
import io.micrometer.observation.transport.SenderContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;

/**
Expand All @@ -33,15 +33,17 @@
*/
public class JmsPublishObservationContext extends SenderContext<Message> {

private static final WarnThenDebugLogger logger = new WarnThenDebugLogger(JmsPublishObservationContext.class);

public JmsPublishObservationContext(@Nullable Message sendMessage) {
super((message, key, value) -> {
try {
if (message != null) {
if (message != null) {
try {
message.setStringProperty(key, value);
}
}
catch (JMSException exc) {
// ignore
catch (Exception exc) {
logger.log("Failed to set message property.", exc);
}
}
});
setCarrier(sendMessage);
Expand Down
Loading