Skip to content

Commit 3851b19

Browse files
committed
Fix Sonar issue
1 parent ff03c53 commit 3851b19

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,22 +1428,26 @@ protected void executeListener(Channel channel, Object data) {
14281428
else {
14291429
message = ((List<Message>) data).get(0);
14301430
}
1431-
if (message.getMessageProperties().isFinalRetryForMessageWithNoId()) {
1432-
if (this.statefulRetryFatalWithNullMessageId) {
1433-
throw new FatalListenerExecutionException(
1434-
"Illegal null id in message. Failed to manage retry for message: " + message, ex);
1435-
}
1436-
else {
1437-
throw new ListenerExecutionFailedException("Cannot retry message more than once without an ID",
1438-
new AmqpRejectAndDontRequeueException("Not retryable; rejecting and not requeuing", ex),
1439-
message);
1440-
}
1441-
}
1431+
checkStatefulRetry(ex, message);
14421432
handleListenerException(ex);
14431433
throw ex;
14441434
}
14451435
}
14461436

1437+
private void checkStatefulRetry(RuntimeException ex, Message message) {
1438+
if (message.getMessageProperties().isFinalRetryForMessageWithNoId()) {
1439+
if (this.statefulRetryFatalWithNullMessageId) {
1440+
throw new FatalListenerExecutionException(
1441+
"Illegal null id in message. Failed to manage retry for message: " + message, ex);
1442+
}
1443+
else {
1444+
throw new ListenerExecutionFailedException("Cannot retry message more than once without an ID",
1445+
new AmqpRejectAndDontRequeueException("Not retryable; rejecting and not requeuing", ex),
1446+
message);
1447+
}
1448+
}
1449+
}
1450+
14471451
private void doExecuteListener(Channel channel, Object data) {
14481452
if (data instanceof Message) {
14491453
Message message = (Message) data;

0 commit comments

Comments
 (0)