Fix new Sonar smells
This commit is contained in:
@@ -31,7 +31,7 @@ import org.springframework.core.type.AnnotationMetadata;
|
||||
*
|
||||
* @since 2.1.6
|
||||
*/
|
||||
@Order(Ordered.LOWEST_PRECEDENCE - 100)
|
||||
@Order(Ordered.LOWEST_PRECEDENCE - 100) // NOSONAR magic
|
||||
public class RabbitListenerTestSelector extends RabbitListenerConfigurationSelector {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -348,36 +348,36 @@ public abstract class AbstractRabbitListenerContainerFactory<C extends AbstractM
|
||||
public C createListenerContainer(RabbitListenerEndpoint endpoint) {
|
||||
C instance = createContainerInstance();
|
||||
|
||||
JavaUtils javaUtils = JavaUtils.INSTANCE.acceptIfNotNull(this.connectionFactory, instance::setConnectionFactory)
|
||||
.acceptIfNotNull(this.errorHandler, instance::setErrorHandler);
|
||||
if (this.messageConverter != null) {
|
||||
if (endpoint != null) {
|
||||
endpoint.setMessageConverter(this.messageConverter);
|
||||
}
|
||||
JavaUtils javaUtils =
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.connectionFactory, instance::setConnectionFactory)
|
||||
.acceptIfNotNull(this.errorHandler, instance::setErrorHandler);
|
||||
if (this.messageConverter != null && endpoint != null) {
|
||||
endpoint.setMessageConverter(this.messageConverter);
|
||||
}
|
||||
javaUtils
|
||||
.acceptIfNotNull(this.acknowledgeMode, instance::setAcknowledgeMode)
|
||||
.acceptIfNotNull(this.channelTransacted, instance::setChannelTransacted)
|
||||
.acceptIfNotNull(this.applicationContext, instance::setApplicationContext)
|
||||
.acceptIfNotNull(this.taskExecutor, instance::setTaskExecutor)
|
||||
.acceptIfNotNull(this.transactionManager, instance::setTransactionManager)
|
||||
.acceptIfNotNull(this.prefetchCount, instance::setPrefetchCount)
|
||||
.acceptIfNotNull(this.defaultRequeueRejected, instance::setDefaultRequeueRejected)
|
||||
.acceptIfNotNull(this.adviceChain, instance::setAdviceChain)
|
||||
.acceptIfNotNull(this.recoveryBackOff, instance::setRecoveryBackOff)
|
||||
.acceptIfNotNull(this.mismatchedQueuesFatal, instance::setMismatchedQueuesFatal)
|
||||
.acceptIfNotNull(this.missingQueuesFatal, instance::setMissingQueuesFatal)
|
||||
.acceptIfNotNull(this.consumerTagStrategy, instance::setConsumerTagStrategy)
|
||||
.acceptIfNotNull(this.idleEventInterval, instance::setIdleEventInterval)
|
||||
.acceptIfNotNull(this.failedDeclarationRetryInterval, instance::setFailedDeclarationRetryInterval)
|
||||
.acceptIfNotNull(this.applicationEventPublisher, instance::setApplicationEventPublisher)
|
||||
.acceptIfNotNull(this.autoStartup, instance::setAutoStartup)
|
||||
.acceptIfNotNull(this.phase, instance::setPhase)
|
||||
.acceptIfNotNull(this.afterReceivePostProcessors, instance::setAfterReceivePostProcessors);
|
||||
.acceptIfNotNull(this.acknowledgeMode, instance::setAcknowledgeMode)
|
||||
.acceptIfNotNull(this.channelTransacted, instance::setChannelTransacted)
|
||||
.acceptIfNotNull(this.applicationContext, instance::setApplicationContext)
|
||||
.acceptIfNotNull(this.taskExecutor, instance::setTaskExecutor)
|
||||
.acceptIfNotNull(this.transactionManager, instance::setTransactionManager)
|
||||
.acceptIfNotNull(this.prefetchCount, instance::setPrefetchCount)
|
||||
.acceptIfNotNull(this.defaultRequeueRejected, instance::setDefaultRequeueRejected)
|
||||
.acceptIfNotNull(this.adviceChain, instance::setAdviceChain)
|
||||
.acceptIfNotNull(this.recoveryBackOff, instance::setRecoveryBackOff)
|
||||
.acceptIfNotNull(this.mismatchedQueuesFatal, instance::setMismatchedQueuesFatal)
|
||||
.acceptIfNotNull(this.missingQueuesFatal, instance::setMissingQueuesFatal)
|
||||
.acceptIfNotNull(this.consumerTagStrategy, instance::setConsumerTagStrategy)
|
||||
.acceptIfNotNull(this.idleEventInterval, instance::setIdleEventInterval)
|
||||
.acceptIfNotNull(this.failedDeclarationRetryInterval, instance::setFailedDeclarationRetryInterval)
|
||||
.acceptIfNotNull(this.applicationEventPublisher, instance::setApplicationEventPublisher)
|
||||
.acceptIfNotNull(this.autoStartup, instance::setAutoStartup)
|
||||
.acceptIfNotNull(this.phase, instance::setPhase)
|
||||
.acceptIfNotNull(this.afterReceivePostProcessors, instance::setAfterReceivePostProcessors);
|
||||
if (endpoint != null) { // endpoint settings overriding default factory settings
|
||||
javaUtils
|
||||
.acceptIfNotNull(endpoint.getAutoStartup(), instance::setAutoStartup)
|
||||
.acceptIfNotNull(endpoint.getTaskExecutor(), instance::setTaskExecutor);
|
||||
.acceptIfNotNull(endpoint.getAutoStartup(), instance::setAutoStartup)
|
||||
.acceptIfNotNull(endpoint.getTaskExecutor(), instance::setTaskExecutor);
|
||||
instance.setListenerId(endpoint.getId());
|
||||
|
||||
endpoint.setupListenerContainer(instance);
|
||||
@@ -386,10 +386,12 @@ public abstract class AbstractRabbitListenerContainerFactory<C extends AbstractM
|
||||
AbstractAdaptableMessageListener messageListener = (AbstractAdaptableMessageListener) instance
|
||||
.getMessageListener();
|
||||
javaUtils
|
||||
.acceptIfNotNull(this.beforeSendReplyPostProcessors, messageListener::setBeforeSendReplyPostProcessors)
|
||||
.acceptIfNotNull(this.retryTemplate, messageListener::setRetryTemplate)
|
||||
.acceptIfCondition(this.retryTemplate != null && this.recoveryCallback != null, this.recoveryCallback,
|
||||
messageListener::setRecoveryCallback);
|
||||
.acceptIfNotNull(this.beforeSendReplyPostProcessors,
|
||||
messageListener::setBeforeSendReplyPostProcessors)
|
||||
.acceptIfNotNull(this.retryTemplate, messageListener::setRetryTemplate)
|
||||
.acceptIfCondition(this.retryTemplate != null && this.recoveryCallback != null,
|
||||
this.recoveryCallback,
|
||||
messageListener::setRecoveryCallback);
|
||||
}
|
||||
initializeContainer(instance, endpoint);
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.rabbit.support.MessagePropertiesConverter;
|
||||
import org.springframework.amqp.support.ConditionalExceptionLogger;
|
||||
import org.springframework.amqp.support.ConsumerTagStrategy;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.amqp.utils.JavaUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
@@ -88,8 +87,6 @@ public class ListenerContainerFactoryBean extends AbstractFactoryBean<AbstractMe
|
||||
|
||||
private ErrorHandler errorHandler;
|
||||
|
||||
private MessageConverter messageConverter;
|
||||
|
||||
private Boolean deBatchingEnabled;
|
||||
|
||||
private Advice[] adviceChain;
|
||||
@@ -383,7 +380,8 @@ public class ListenerContainerFactoryBean extends AbstractFactoryBean<AbstractMe
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return this.listenerContainer == null ? AbstractMessageListenerContainer.class : this.listenerContainer.getClass();
|
||||
return this.listenerContainer == null ? AbstractMessageListenerContainer.class : this.listenerContainer
|
||||
.getClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -392,43 +390,45 @@ public class ListenerContainerFactoryBean extends AbstractFactoryBean<AbstractMe
|
||||
if (this.listenerContainer == null) {
|
||||
AbstractMessageListenerContainer container = createContainer();
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.applicationContext, container::setApplicationContext)
|
||||
.acceptIfNotNull(this.beanName, container::setBeanName)
|
||||
.acceptIfNotNull(this.applicationEventPublisher, container::setApplicationEventPublisher)
|
||||
.acceptIfNotNull(this.channelTransacted, container::setChannelTransacted)
|
||||
.acceptIfNotNull(this.acknowledgeMode, container::setAcknowledgeMode)
|
||||
.acceptIfNotNull(this.queueNames, container::setQueueNames)
|
||||
.acceptIfNotNull(this.queues, container::setQueues)
|
||||
.acceptIfNotNull(this.exposeListenerChannel, container::setExposeListenerChannel)
|
||||
.acceptIfNotNull(this.messageListener, container::setMessageListener)
|
||||
.acceptIfNotNull(this.errorHandler, container::setErrorHandler)
|
||||
.acceptIfNotNull(this.deBatchingEnabled, container::setDeBatchingEnabled)
|
||||
.acceptIfNotNull(this.adviceChain, container::setAdviceChain)
|
||||
.acceptIfNotNull(this.afterReceivePostProcessors, container::setAfterReceivePostProcessors)
|
||||
.acceptIfNotNull(this.autoStartup, container::setAutoStartup)
|
||||
.acceptIfNotNull(this.phase, container::setPhase)
|
||||
.acceptIfNotNull(this.listenerId, container::setListenerId)
|
||||
.acceptIfNotNull(this.consumerTagStrategy, container::setConsumerTagStrategy)
|
||||
.acceptIfNotNull(this.consumerArgs, container::setConsumerArguments)
|
||||
.acceptIfNotNull(this.noLocal, container::setNoLocal)
|
||||
.acceptIfNotNull(this.exclusive, container::setExclusive)
|
||||
.acceptIfNotNull(this.defaultRequeueRejected, container::setDefaultRequeueRejected)
|
||||
.acceptIfNotNull(this.prefetchCount, container::setPrefetchCount)
|
||||
.acceptIfNotNull(this.shutdownTimeout, container::setShutdownTimeout)
|
||||
.acceptIfNotNull(this.idleEventInterval, container::setIdleEventInterval)
|
||||
.acceptIfNotNull(this.transactionManager, container::setTransactionManager)
|
||||
.acceptIfNotNull(this.transactionAttribute, container::setTransactionAttribute)
|
||||
.acceptIfNotNull(this.taskExecutor, container::setTaskExecutor)
|
||||
.acceptIfNotNull(this.recoveryInterval, container::setRecoveryInterval)
|
||||
.acceptIfNotNull(this.recoveryBackOff, container::setRecoveryBackOff)
|
||||
.acceptIfNotNull(this.messagePropertiesConverter, container::setMessagePropertiesConverter)
|
||||
.acceptIfNotNull(this.rabbitAdmin, container::setAmqpAdmin)
|
||||
.acceptIfNotNull(this.missingQueuesFatal, container::setMissingQueuesFatal)
|
||||
.acceptIfNotNull(this.possibleAuthenticationFailureFatal, container::setPossibleAuthenticationFailureFatal)
|
||||
.acceptIfNotNull(this.mismatchedQueuesFatal, container::setMismatchedQueuesFatal)
|
||||
.acceptIfNotNull(this.autoDeclare, container::setAutoDeclare)
|
||||
.acceptIfNotNull(this.failedDeclarationRetryInterval, container::setFailedDeclarationRetryInterval)
|
||||
.acceptIfNotNull(this.exclusiveConsumerExceptionLogger, container::setExclusiveConsumerExceptionLogger);
|
||||
.acceptIfNotNull(this.applicationContext, container::setApplicationContext)
|
||||
.acceptIfNotNull(this.beanName, container::setBeanName)
|
||||
.acceptIfNotNull(this.applicationEventPublisher, container::setApplicationEventPublisher)
|
||||
.acceptIfNotNull(this.channelTransacted, container::setChannelTransacted)
|
||||
.acceptIfNotNull(this.acknowledgeMode, container::setAcknowledgeMode)
|
||||
.acceptIfNotNull(this.queueNames, container::setQueueNames)
|
||||
.acceptIfNotNull(this.queues, container::setQueues)
|
||||
.acceptIfNotNull(this.exposeListenerChannel, container::setExposeListenerChannel)
|
||||
.acceptIfNotNull(this.messageListener, container::setMessageListener)
|
||||
.acceptIfNotNull(this.errorHandler, container::setErrorHandler)
|
||||
.acceptIfNotNull(this.deBatchingEnabled, container::setDeBatchingEnabled)
|
||||
.acceptIfNotNull(this.adviceChain, container::setAdviceChain)
|
||||
.acceptIfNotNull(this.afterReceivePostProcessors, container::setAfterReceivePostProcessors)
|
||||
.acceptIfNotNull(this.autoStartup, container::setAutoStartup)
|
||||
.acceptIfNotNull(this.phase, container::setPhase)
|
||||
.acceptIfNotNull(this.listenerId, container::setListenerId)
|
||||
.acceptIfNotNull(this.consumerTagStrategy, container::setConsumerTagStrategy)
|
||||
.acceptIfNotNull(this.consumerArgs, container::setConsumerArguments)
|
||||
.acceptIfNotNull(this.noLocal, container::setNoLocal)
|
||||
.acceptIfNotNull(this.exclusive, container::setExclusive)
|
||||
.acceptIfNotNull(this.defaultRequeueRejected, container::setDefaultRequeueRejected)
|
||||
.acceptIfNotNull(this.prefetchCount, container::setPrefetchCount)
|
||||
.acceptIfNotNull(this.shutdownTimeout, container::setShutdownTimeout)
|
||||
.acceptIfNotNull(this.idleEventInterval, container::setIdleEventInterval)
|
||||
.acceptIfNotNull(this.transactionManager, container::setTransactionManager)
|
||||
.acceptIfNotNull(this.transactionAttribute, container::setTransactionAttribute)
|
||||
.acceptIfNotNull(this.taskExecutor, container::setTaskExecutor)
|
||||
.acceptIfNotNull(this.recoveryInterval, container::setRecoveryInterval)
|
||||
.acceptIfNotNull(this.recoveryBackOff, container::setRecoveryBackOff)
|
||||
.acceptIfNotNull(this.messagePropertiesConverter, container::setMessagePropertiesConverter)
|
||||
.acceptIfNotNull(this.rabbitAdmin, container::setAmqpAdmin)
|
||||
.acceptIfNotNull(this.missingQueuesFatal, container::setMissingQueuesFatal)
|
||||
.acceptIfNotNull(this.possibleAuthenticationFailureFatal,
|
||||
container::setPossibleAuthenticationFailureFatal)
|
||||
.acceptIfNotNull(this.mismatchedQueuesFatal, container::setMismatchedQueuesFatal)
|
||||
.acceptIfNotNull(this.autoDeclare, container::setAutoDeclare)
|
||||
.acceptIfNotNull(this.failedDeclarationRetryInterval, container::setFailedDeclarationRetryInterval)
|
||||
.acceptIfNotNull(this.exclusiveConsumerExceptionLogger,
|
||||
container::setExclusiveConsumerExceptionLogger);
|
||||
container.afterPropertiesSet();
|
||||
this.listenerContainer = container;
|
||||
}
|
||||
@@ -439,24 +439,24 @@ public class ListenerContainerFactoryBean extends AbstractFactoryBean<AbstractMe
|
||||
if (this.type.equals(Type.simple)) {
|
||||
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory);
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.concurrentConsumers, container::setConcurrentConsumers)
|
||||
.acceptIfNotNull(this.maxConcurrentConsumers, container::setMaxConcurrentConsumers)
|
||||
.acceptIfNotNull(this.startConsumerMinInterval, container::setStartConsumerMinInterval)
|
||||
.acceptIfNotNull(this.stopConsumerMinInterval, container::setStopConsumerMinInterval)
|
||||
.acceptIfNotNull(this.consecutiveActiveTrigger, container::setConsecutiveActiveTrigger)
|
||||
.acceptIfNotNull(this.consecutiveIdleTrigger, container::setConsecutiveIdleTrigger)
|
||||
.acceptIfNotNull(this.receiveTimeout, container::setReceiveTimeout)
|
||||
.acceptIfNotNull(this.txSize, container::setTxSize)
|
||||
.acceptIfNotNull(this.declarationRetries, container::setDeclarationRetries)
|
||||
.acceptIfNotNull(this.retryDeclarationInterval, container::setRetryDeclarationInterval);
|
||||
.acceptIfNotNull(this.concurrentConsumers, container::setConcurrentConsumers)
|
||||
.acceptIfNotNull(this.maxConcurrentConsumers, container::setMaxConcurrentConsumers)
|
||||
.acceptIfNotNull(this.startConsumerMinInterval, container::setStartConsumerMinInterval)
|
||||
.acceptIfNotNull(this.stopConsumerMinInterval, container::setStopConsumerMinInterval)
|
||||
.acceptIfNotNull(this.consecutiveActiveTrigger, container::setConsecutiveActiveTrigger)
|
||||
.acceptIfNotNull(this.consecutiveIdleTrigger, container::setConsecutiveIdleTrigger)
|
||||
.acceptIfNotNull(this.receiveTimeout, container::setReceiveTimeout)
|
||||
.acceptIfNotNull(this.txSize, container::setTxSize)
|
||||
.acceptIfNotNull(this.declarationRetries, container::setDeclarationRetries)
|
||||
.acceptIfNotNull(this.retryDeclarationInterval, container::setRetryDeclarationInterval);
|
||||
return container;
|
||||
}
|
||||
else {
|
||||
DirectMessageListenerContainer container = new DirectMessageListenerContainer(this.connectionFactory);
|
||||
JavaUtils.INSTANCE
|
||||
.acceptIfNotNull(this.consumersPerQueue, container::setConsumersPerQueue)
|
||||
.acceptIfNotNull(this.taskScheduler, container::setTaskScheduler)
|
||||
.acceptIfNotNull(this.monitorInterval, container::setMonitorInterval);
|
||||
.acceptIfNotNull(this.consumersPerQueue, container::setConsumersPerQueue)
|
||||
.acceptIfNotNull(this.taskScheduler, container::setTaskScheduler)
|
||||
.acceptIfNotNull(this.monitorInterval, container::setMonitorInterval);
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ import org.springframework.amqp.rabbit.support.MessagePropertiesConverter;
|
||||
import org.springframework.amqp.support.ConditionalExceptionLogger;
|
||||
import org.springframework.amqp.support.ConsumerTagStrategy;
|
||||
import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.amqp.support.postprocessor.MessagePostProcessorUtils;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
@@ -175,8 +174,6 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor
|
||||
|
||||
private ErrorHandler errorHandler = new ConditionalRejectingErrorHandler();
|
||||
|
||||
private MessageConverter messageConverter;
|
||||
|
||||
private boolean exposeListenerChannel = true;
|
||||
|
||||
private volatile MessageListener messageListener;
|
||||
@@ -625,8 +622,8 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor
|
||||
protected String getRoutingLookupKey() {
|
||||
return super.getConnectionFactory() instanceof RoutingConnectionFactory
|
||||
? this.lookupKeyQualifier + "[" + this.queues.stream()
|
||||
.map(Queue::getName)
|
||||
.collect(Collectors.joining(",")) + "]"
|
||||
.map(Queue::getName)
|
||||
.collect(Collectors.joining(",")) + "]"
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -1057,11 +1054,13 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor
|
||||
Assert.state(
|
||||
this.exposeListenerChannel || !getAcknowledgeMode().isManual(),
|
||||
"You cannot acknowledge messages manually if the channel is not exposed to the listener "
|
||||
+ "(please check your configuration and set exposeListenerChannel=true or acknowledgeMode!=MANUAL)");
|
||||
+ "(please check your configuration and set exposeListenerChannel=true or " +
|
||||
"acknowledgeMode!=MANUAL)");
|
||||
Assert.state(
|
||||
!(getAcknowledgeMode().isAutoAck() && isChannelTransacted()),
|
||||
"The acknowledgeMode is NONE (autoack in Rabbit terms) which is not consistent with having a "
|
||||
+ "transactional channel. Either use a different AcknowledgeMode or make sure channelTransacted=false");
|
||||
+ "transactional channel. Either use a different AcknowledgeMode or make sure " +
|
||||
"channelTransacted=false");
|
||||
validateConfiguration();
|
||||
initialize();
|
||||
}
|
||||
@@ -1821,6 +1820,7 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor
|
||||
protected SharedConnectionNotInitializedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user