GH-1347: Fix new Sonar issues

This commit is contained in:
Gary Russell
2021-06-10 09:36:38 -04:00
parent e43024ee69
commit 29c6673b2f

View File

@@ -425,22 +425,7 @@ public class DirectMessageListenerContainer extends AbstractMessageListenerConta
super.doStart();
final String[] queueNames = getQueueNames();
checkMissingQueues(queueNames);
if (isPossibleAuthenticationFailureFatal()) {
Connection connection = null;
try {
getConnectionFactory().createConnection();
}
catch (AmqpAuthenticationException ex) {
throw ex;
}
catch (Exception ex) { // NOSONAR
}
finally {
if (connection != null) {
connection.close();
}
}
}
checkConnect();
long idleEventInterval = getIdleEventInterval();
if (this.taskScheduler == null) {
afterPropertiesSet();
@@ -469,6 +454,26 @@ public class DirectMessageListenerContainer extends AbstractMessageListenerConta
}
}
protected void checkConnect() {
if (isPossibleAuthenticationFailureFatal()) {
Connection connection = null;
try {
getConnectionFactory().createConnection();
}
catch (AmqpAuthenticationException ex) {
this.logger.debug("Failed to authenticate", ex);
throw ex;
}
catch (Exception ex) { // NOSONAR
}
finally {
if (connection != null) {
connection.close();
}
}
}
}
private void startMonitor(long idleEventInterval, final Map<String, Queue> namesToQueues) {
this.consumerMonitorTask = this.taskScheduler.scheduleAtFixedRate(() -> {
long now = System.currentTimeMillis();