Skip to content

Commit d86f356

Browse files
committed
Fix Method Complexity
1 parent 6f80938 commit d86f356

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -954,27 +954,33 @@ protected boolean useDirectReplyTo() {
954954
});
955955
}
956956
catch (AmqpConnectException | AmqpIOException ex) {
957-
Throwable cause = ex;
958-
while (cause != null && !(cause instanceof ShutdownSignalException)) {
959-
cause = cause.getCause();
957+
if (shouldRethrow(ex)) {
958+
throw ex;
960959
}
961-
if (cause != null && RabbitUtils.isPassiveDeclarationChannelClose((ShutdownSignalException) cause)) {
962-
if (logger.isWarnEnabled()) {
963-
logger.warn("Broker does not support fast replies via 'amq.rabbitmq.reply-to', temporary "
964-
+ "queues will be used: " + cause.getMessage() + ".");
965-
}
966-
this.replyAddress = null;
967-
return false;
968-
}
969-
if (logger.isDebugEnabled()) {
970-
logger.debug("IO error, deferring directReplyTo detection: " + ex.toString());
971-
}
972-
throw ex;
973960
}
974961
}
975962
return false;
976963
}
977964

965+
private boolean shouldRethrow(AmqpException ex) {
966+
Throwable cause = ex;
967+
while (cause != null && !(cause instanceof ShutdownSignalException)) {
968+
cause = cause.getCause();
969+
}
970+
if (cause != null && RabbitUtils.isPassiveDeclarationChannelClose((ShutdownSignalException) cause)) {
971+
if (logger.isWarnEnabled()) {
972+
logger.warn("Broker does not support fast replies via 'amq.rabbitmq.reply-to', temporary "
973+
+ "queues will be used: " + cause.getMessage() + ".");
974+
}
975+
this.replyAddress = null;
976+
return false;
977+
}
978+
if (logger.isDebugEnabled()) {
979+
logger.debug("IO error, deferring directReplyTo detection: " + ex.toString());
980+
}
981+
return true;
982+
}
983+
978984
@Override
979985
public void send(Message message) throws AmqpException {
980986
send(this.exchange, this.routingKey, message);

0 commit comments

Comments
 (0)