diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/BindingBuilder.java b/spring-amqp/src/main/java/org/springframework/amqp/core/BindingBuilder.java index 5eceadd96..d297f16d9 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/BindingBuilder.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/core/BindingBuilder.java @@ -231,12 +231,12 @@ public static final class TopicExchangeRoutingKeyConfigurer extends AbstractRout public Binding with(String routingKey) { return new Binding(destination.queue, destination.name, destination.type, exchange, routingKey, - Collections.emptyMap()); + Collections.emptyMap()); } public Binding with(Enum routingKeyEnum) { return new Binding(destination.queue, destination.name, destination.type, exchange, - routingKeyEnum.toString(), Collections.emptyMap()); + routingKeyEnum.toString(), Collections.emptyMap()); } } @@ -282,7 +282,7 @@ public Binding and(Map map) { public Binding noargs() { return new Binding(this.configurer.destination.queue, this.configurer.destination.name, this.configurer.destination.type, this.configurer.exchange, - this.routingKey, Collections.emptyMap()); + this.routingKey, Collections.emptyMap()); } } @@ -298,17 +298,17 @@ public static final class DirectExchangeRoutingKeyConfigurer extends AbstractRou public Binding with(String routingKey) { return new Binding(destination.queue, destination.name, destination.type, exchange, routingKey, - Collections.emptyMap()); + Collections.emptyMap()); } public Binding with(Enum routingKeyEnum) { return new Binding(destination.queue, destination.name, destination.type, exchange, - routingKeyEnum.toString(), Collections.emptyMap()); + routingKeyEnum.toString(), Collections.emptyMap()); } public Binding withQueueName() { return new Binding(destination.queue, destination.name, destination.type, exchange, destination.name, - Collections.emptyMap()); + Collections.emptyMap()); } } diff --git a/spring-amqp/src/main/java/org/springframework/amqp/support/converter/MessagingMessageConverter.java b/spring-amqp/src/main/java/org/springframework/amqp/support/converter/MessagingMessageConverter.java index 0c91aac10..5bc545086 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/support/converter/MessagingMessageConverter.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/support/converter/MessagingMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2024 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. @@ -40,6 +40,7 @@ * is considered to be a request). * * @author Stephane Nicoll + * @author Ngoc Nhan * @since 1.4 */ public class MessagingMessageConverter implements MessageConverter, InitializingBean { @@ -104,11 +105,10 @@ public void afterPropertiesSet() { public org.springframework.amqp.core.Message toMessage(Object object, MessageProperties messageProperties) throws MessageConversionException { - if (!(object instanceof Message)) { + if (!(object instanceof Message input)) { throw new IllegalArgumentException("Could not convert [" + object + "] - only [" + Message.class.getName() + "] is handled by this converter"); } - Message input = (Message) object; this.headerMapper.fromHeaders(input.getHeaders(), messageProperties); org.springframework.amqp.core.Message amqpMessage = this.payloadConverter.toMessage( input.getPayload(), messageProperties);