-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KafkaMessageListenerContainer.getAssignedPartitions is not safe #3726
Milestone
Comments
More info in StackOverflow question: https://stackoverflow.com/questions/79383650/is-kafkamessagelistenercontainer-getassignedpartitions-thread-safe. feel free to contribute the fix: https://github.com/spring-projects/spring-kafka/blob/main/CONTRIBUTING.adoc! |
tbarabanov
added a commit
to tbarabanov/spring-kafka
that referenced
this issue
Jan 30, 2025
…aMessageListenerContainer Fixes spring-projectsGH-3726 (spring-projects#3726)
tbarabanov
added a commit
to tbarabanov/spring-kafka
that referenced
this issue
Jan 30, 2025
…aMessageListenerContainer Fixes spring-projectsGH-3726 (spring-projects#3726) Signed-off-by: Tim Barabanov <t.barabanov@gmail.com>
tbarabanov
added a commit
to tbarabanov/spring-kafka
that referenced
this issue
Jan 30, 2025
…aMessageListenerContainer Fixes spring-projectsGH-3726 (spring-projects#3726) Signed-off-by: Tim Barabanov <t.barabanov@gmail.com>
artembilan
pushed a commit
that referenced
this issue
Jan 30, 2025
Loading
Loading status checks…
…Exception 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 <t.barabanov@gmail.com> [artem.bilan@broadcom.com Fix commit message] **Auto-cherry-pick to `3.2.x`** Signed-off-by: Artem Bilan <artem.bilan@broadcom.com>
artembilan
pushed a commit
that referenced
this issue
Jan 30, 2025
Loading
Loading status checks…
…Exception 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 <t.barabanov@gmail.com> [artem.bilan@broadcom.com Fix commit message] # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java Signed-off-by: Artem Bilan <artem.bilan@broadcom.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.2.1
Describe the bug
KafkaMessageListenerContainer.getAssignedPartitions()
is not safe due to the fact that different threads can iterate/modify any of the fieldspartitionsListenerConsumer.definedPartitions
,partitionsListenerConsumer.assignedPartitions
simultaneously, but collection types of these fields are not designed for such scenarios. Thus at least ConcurrentModificationException can be thrown.Expected behavior
KafkaMessageListenerContainer.getAssignedPartitions()
method is public and thus expected to be safe.The text was updated successfully, but these errors were encountered: