|
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.
|
|
164 | 164 | * @author Raphael Rösch
|
165 | 165 | * @author Christian Mergenthaler
|
166 | 166 | * @author Mikael Carlstedt
|
| 167 | + * @author Timofey Barabanov |
167 | 168 | */
|
168 | 169 | public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
|
169 | 170 | extends AbstractMessageListenerContainer<K, V> implements ConsumerPauseResumeEventPublisher {
|
@@ -617,7 +618,7 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume
|
617 | 618 |
|
618 | 619 | private final Map<TopicPartition, Long> offsets = new LinkedHashMap<>();
|
619 | 620 |
|
620 |
| - private final Collection<TopicPartition> assignedPartitions = new LinkedHashSet<>(); |
| 621 | + private final Collection<TopicPartition> assignedPartitions = Collections.synchronizedSet(new LinkedHashSet<>()); |
621 | 622 |
|
622 | 623 | private final Map<TopicPartition, OffsetAndMetadata> lastCommits = new HashMap<>();
|
623 | 624 |
|
@@ -1219,7 +1220,8 @@ private void subscribeOrAssignTopics(final Consumer<? super K, ? super V> subscr
|
1219 | 1220 | else {
|
1220 | 1221 | List<TopicPartitionOffset> topicPartitionsToAssign =
|
1221 | 1222 | Arrays.asList(KafkaMessageListenerContainer.this.topicPartitions);
|
1222 |
| - this.definedPartitions = new LinkedHashMap<>(topicPartitionsToAssign.size()); |
| 1223 | + this.definedPartitions = Collections.synchronizedMap( |
| 1224 | + new LinkedHashMap<>(topicPartitionsToAssign.size())); |
1223 | 1225 | for (TopicPartitionOffset topicPartition : topicPartitionsToAssign) {
|
1224 | 1226 | this.definedPartitions.put(topicPartition.getTopicPartition(),
|
1225 | 1227 | new OffsetMetadata(topicPartition.getOffset(), topicPartition.isRelativeToCurrent(),
|
|
0 commit comments