|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2024 the original author or authors. |
| 2 | + * Copyright 2016-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
171 | 171 | * @author Lokesh Alamuri
|
172 | 172 | * @author Sanghyeok An
|
173 | 173 | * @author Christian Fredriksson
|
| 174 | + * @author Timofey Barabanov |
174 | 175 | */
|
175 | 176 | public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
|
176 | 177 | extends AbstractMessageListenerContainer<K, V> implements ConsumerPauseResumeEventPublisher {
|
@@ -625,7 +626,7 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume
|
625 | 626 |
|
626 | 627 | private final Map<TopicPartition, Long> offsets = new LinkedHashMap<>();
|
627 | 628 |
|
628 |
| - private final Collection<TopicPartition> assignedPartitions = new LinkedHashSet<>(); |
| 629 | + private final Collection<TopicPartition> assignedPartitions = Collections.synchronizedSet(new LinkedHashSet<>()); |
629 | 630 |
|
630 | 631 | private final Map<TopicPartition, OffsetAndMetadata> lastCommits = new HashMap<>();
|
631 | 632 |
|
@@ -1247,7 +1248,8 @@ private void subscribeOrAssignTopics(final Consumer<? super K, ? super V> subscr
|
1247 | 1248 | else {
|
1248 | 1249 | List<TopicPartitionOffset> topicPartitionsToAssign =
|
1249 | 1250 | Arrays.asList(KafkaMessageListenerContainer.this.topicPartitions);
|
1250 |
| - this.definedPartitions = new LinkedHashMap<>(topicPartitionsToAssign.size()); |
| 1251 | + this.definedPartitions = Collections.synchronizedMap( |
| 1252 | + new LinkedHashMap<>(topicPartitionsToAssign.size())); |
1251 | 1253 | for (TopicPartitionOffset topicPartition : topicPartitionsToAssign) {
|
1252 | 1254 | this.definedPartitions.put(topicPartition.getTopicPartition(),
|
1253 | 1255 | new OffsetMetadata(topicPartition.getOffset(), topicPartition.isRelativeToCurrent(),
|
|
0 commit comments