Commit b772ebd
authored
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]
**Auto-cherry-pick to `3.2.x`**
Signed-off-by: Artem Bilan <[email protected]>1 parent 7aa87dd commit b772ebd
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 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
625 | 626 | | |
626 | 627 | | |
627 | 628 | | |
628 | | - | |
| 629 | + | |
629 | 630 | | |
630 | 631 | | |
631 | 632 | | |
| |||
1247 | 1248 | | |
1248 | 1249 | | |
1249 | 1250 | | |
1250 | | - | |
| 1251 | + | |
| 1252 | + | |
1251 | 1253 | | |
1252 | 1254 | | |
1253 | 1255 | | |
| |||
0 commit comments