Skip to content

Commit acd4ab0

Browse files
authored
Refactor getOrSetCorrelationIdAndSetReplyTo method
Refactored the `getOrSetCorrelationIdAndSetReplyTo` method for improved readability and code organization. Merged the declaration and initialization of `correlationId` into a single line. Ensured the logic remains unchanged. No functional changes introduced.
1 parent 3f4ae51 commit acd4ab0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/AsyncRabbitTemplate.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
*
8888
* @author Gary Russell
8989
* @author Artem Bilan
90+
* @author FengYang Su
9091
*
9192
* @since 1.6
9293
*/
@@ -666,18 +667,14 @@ public void confirm(@NonNull CorrelationData correlationData, boolean ack, @Null
666667
private String getOrSetCorrelationIdAndSetReplyTo(Message message,
667668
@Nullable AsyncCorrelationData<?> correlationData) {
668669

669-
String correlationId;
670670
MessageProperties messageProperties = message.getMessageProperties();
671671
Assert.notNull(messageProperties, "the message properties cannot be null");
672-
String currentCorrelationId = messageProperties.getCorrelationId();
673-
if (!StringUtils.hasText(currentCorrelationId)) {
672+
String correlationId = messageProperties.getCorrelationId();
673+
if (!StringUtils.hasText(correlationId)) {
674674
correlationId = correlationData != null ? correlationData.getId() : UUID.randomUUID().toString();
675675
messageProperties.setCorrelationId(correlationId);
676676
Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null");
677677
}
678-
else {
679-
correlationId = currentCorrelationId;
680-
}
681678
messageProperties.setReplyTo(this.replyAddress);
682679
return correlationId;
683680
}

0 commit comments

Comments
 (0)