Skip to content

Commit

Permalink
GH-1485: Fix new Sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
garyrussell committed May 14, 2020
1 parent 61dea04 commit c97c34c
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,8 @@ protected void doStart() {
setRunning(true);

for (int i = 0; i < this.concurrency; i++) {
KafkaMessageListenerContainer<K, V> container;
if (topicPartitions == null) {
container = new KafkaMessageListenerContainer<>(this, this.consumerFactory, containerProperties);
}
else {
container = new KafkaMessageListenerContainer<>(this, this.consumerFactory,
containerProperties, partitionSubset(containerProperties, i));
}
KafkaMessageListenerContainer<K, V> container =
constructContainer(containerProperties, topicPartitions, i);
String beanName = getBeanName();
container.setBeanName((beanName != null ? beanName : "consumer") + "-" + i);
container.setApplicationContext(getApplicationContext());
Expand All @@ -213,6 +207,19 @@ protected void doStart() {
}
}

private KafkaMessageListenerContainer<K, V> constructContainer(ContainerProperties containerProperties,
TopicPartitionOffset[] topicPartitions, int i) {
KafkaMessageListenerContainer<K, V> container;
if (topicPartitions == null) {
container = new KafkaMessageListenerContainer<>(this, this.consumerFactory, containerProperties);
}
else {
container = new KafkaMessageListenerContainer<>(this, this.consumerFactory,
containerProperties, partitionSubset(containerProperties, i));
}
return container;
}

private TopicPartitionOffset[] partitionSubset(ContainerProperties containerProperties, int i) {
TopicPartitionOffset[] topicPartitions = containerProperties.getTopicPartitions();
if (this.concurrency == 1) {
Expand Down

0 comments on commit c97c34c

Please sign in to comment.