Expand type check in TraceChannelInterceptor (#673)

The type check in the method 'getMessage' was only for a sub-class of
MessagingException. The check was expanded to the base class.
This commit is contained in:
Canaan Stafford
2017-08-05 15:10:54 -05:00
committed by Marcin Grzejszczak
parent 48227e7793
commit 7dffabd91a
2 changed files with 5 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ import org.springframework.cloud.sleuth.Tracer;
import org.springframework.cloud.sleuth.sampler.NeverSampler;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.messaging.support.MessageBuilder;
@@ -96,8 +96,8 @@ public class TraceChannelInterceptor extends AbstractTraceChannelInterceptor {
private Message getMessage(Message<?> message) {
Object payload = message.getPayload();
if (payload instanceof MessageDeliveryException) {
MessageDeliveryException e = (MessageDeliveryException) payload;
if (payload instanceof MessagingException) {
MessagingException e = (MessagingException) payload;
return e.getFailedMessage();
}
return message;

View File

@@ -323,8 +323,8 @@ public class TraceChannelInterceptorTests implements MessageHandler {
}
@Test
public void workWithMessageDeliveryException() throws Exception {
Message<?> message = new GenericMessage<>(new MessageDeliveryException(
public void workWithMessagingException() throws Exception {
Message<?> message = new GenericMessage<>(new MessagingException(
MessageBuilder.withPayload("hi")
.setHeader(TraceMessageHeaders.TRACE_ID_NAME, Span.idToHex(10L))
.setHeader(TraceMessageHeaders.SPAN_ID_NAME, Span.idToHex(20L)).build()