diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/retry/RepublishMessageRecoverer.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/retry/RepublishMessageRecoverer.java index efe28d49f5..304e4f7a97 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/retry/RepublishMessageRecoverer.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/retry/RepublishMessageRecoverer.java @@ -110,7 +110,9 @@ public RepublishMessageRecoverer(AmqpTemplate errorTemplate, String errorExchang * @param errorExchange the exchange. * @param errorRoutingKey the routing key. */ - public RepublishMessageRecoverer(AmqpTemplate errorTemplate, String errorExchange, String errorRoutingKey) { + public RepublishMessageRecoverer(AmqpTemplate errorTemplate, @Nullable String errorExchange, + @Nullable String errorRoutingKey) { + this(errorTemplate, new LiteralExpression(errorExchange), new LiteralExpression(errorRoutingKey)); } @@ -126,8 +128,8 @@ public RepublishMessageRecoverer(AmqpTemplate errorTemplate, @Nullable Expressio Assert.notNull(errorTemplate, "'errorTemplate' cannot be null"); this.errorTemplate = errorTemplate; - this.errorExchangeNameExpression = errorExchange != null ? errorExchange : new LiteralExpression(null); - this.errorRoutingKeyExpression = errorRoutingKey != null ? errorRoutingKey : new LiteralExpression(null); + this.errorExchangeNameExpression = errorExchange != null ? errorExchange : new LiteralExpression(null); // NOSONAR + this.errorRoutingKeyExpression = errorRoutingKey != null ? errorRoutingKey : new LiteralExpression(null); // NOSONAR if (!(this.errorTemplate instanceof RabbitTemplate)) { this.maxStackTraceLength = Integer.MAX_VALUE; }