From fc3b95ea790798dd20420746296f5b1488ef9e24 Mon Sep 17 00:00:00 2001 From: abilan Date: Fri, 13 Jan 2023 15:12:44 -0500 Subject: [PATCH] Debug not resolved channel in Router Currently, when `!resolutionRequired` not resolved channel name is ignored silently, and we go ahead to `defaultOutputChannel` or exception thrown * For better end-user experience `DEBUG` not resolved and ignored channel name if `!resolutionRequired` --- .../router/AbstractMappingMessageRouter.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java index 2860692e99..79d3854f1f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMappingMessageRouter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -309,9 +309,12 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter try { channel = getChannelResolver().resolveDestination(channelName); } - catch (DestinationResolutionException e) { + catch (DestinationResolutionException ex) { if (this.resolutionRequired) { - throw new MessagingException(message, "failed to resolve channel name '" + channelName + "'", e); + throw new MessagingException(message, "Failed to resolve a channel for name '" + channelName + "'", ex); + } + else { + logger.debug(() -> "Failed to resolve a channel for name '" + channelName + "'. Ignored"); } } return channel; @@ -397,7 +400,7 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter } } else { - throw new MessagingException("unsupported return type for router [" + channelKey.getClass() + "]"); + throw new MessagingException("Unsupported return type for router [" + channelKey.getClass() + "]"); } }