Fix Sonar vulnerabilities for varargs

* Fix smell for static `AmqpInboundGateway.attributesHolder`

* Fix readOnlyHeaders in the `MessageBuilder`
This commit is contained in:
Artem Bilan
2019-05-29 12:45:06 -04:00
committed by Gary Russell
parent 1d08d3bdc2
commit 315f0e711f
18 changed files with 186 additions and 166 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.redis.inbound;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
@@ -70,11 +71,13 @@ public class RedisInboundChannelAdapter extends MessageProducerSupport {
}
public void setTopics(String... topics) {
this.topics = topics;
Assert.notEmpty(topics, "at least one topic is required");
this.topics = Arrays.copyOf(topics, topics.length);
}
public void setTopicPatterns(String... topicPatterns) {
this.topicPatterns = topicPatterns;
Assert.notEmpty(topicPatterns, "at least one topic pattern is required");
this.topicPatterns = Arrays.copyOf(topicPatterns, topicPatterns.length);
}
public void setMessageConverter(MessageConverter messageConverter) {
@@ -114,12 +117,12 @@ public class RedisInboundChannelAdapter extends MessageProducerSupport {
Assert.state(hasTopics || hasPatterns, "at least one topic or topic pattern is required for subscription.");
if (this.messageConverter instanceof BeanFactoryAware) {
((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
((BeanFactoryAware) this.messageConverter).setBeanFactory(getBeanFactory());
}
MessageListenerDelegate delegate = new MessageListenerDelegate();
MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
adapter.setSerializer(this.serializer);
List<Topic> topicList = new ArrayList<Topic>();
List<Topic> topicList = new ArrayList<>();
if (hasTopics) {
for (String topic : this.topics) {
topicList.add(new ChannelTopic(topic));