Commit bbaecbc
GH-3726: Fix KafkaMessageListenerContainer for ConcurrentModificationException
Fixes: #3726
Issue link: #3726
`KafkaMessageListenerContainer.getAssignedPartitions()` is not safe due to the fact that
different threads can iterate/modify any of the fields `partitionsListenerConsumer.definedPartitions` or `partitionsListenerConsumer.assignedPartitions` simultaneously,
but collection types of these fields are not designed for such scenarios.
Thus at least `ConcurrentModificationException` can be thrown.
* Wrap `partitionsListenerConsumer.definedPartitions` and `partitionsListenerConsumer.assignedPartitions` into `Collections.synchronizedSet()`
Signed-off-by: Tim Barabanov <[email protected]>
[[email protected] Fix commit message]
# Conflicts:
# spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java
Signed-off-by: Artem Bilan <[email protected]>1 parent a628704 commit bbaecbc
File tree
1 file changed
+5
-3
lines changed- spring-kafka/src/main/java/org/springframework/kafka/listener
1 file changed
+5
-3
lines changedLines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| |||
617 | 618 | | |
618 | 619 | | |
619 | 620 | | |
620 | | - | |
| 621 | + | |
621 | 622 | | |
622 | 623 | | |
623 | 624 | | |
| |||
1219 | 1220 | | |
1220 | 1221 | | |
1221 | 1222 | | |
1222 | | - | |
| 1223 | + | |
| 1224 | + | |
1223 | 1225 | | |
1224 | 1226 | | |
1225 | 1227 | | |
| |||
0 commit comments