Skip to content
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

GH-2943: Fix KT.clusterId() for concurrency #2944

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

artembilan
Copy link
Member

Fixes: #2943

The if (this.kafkaAdmin != null && this.clusterId == null) { condition might be always true for concurrent threads (especially virtual). Therefore, all of those threads are calling this.kafkaAdmin.clusterId() making unnecessary network chats to Kafka broker

  • Surround this.kafkaAdmin.clusterId() call with Lock

Cherry-pick to 3.0.x

Fixes: spring-projects#2943

The `if (this.kafkaAdmin != null && this.clusterId == null) {` condition
might be always true for concurrent threads (especially virtual).
Therefore, all of those threads are calling `this.kafkaAdmin.clusterId()`
making unnecessary network chats to Kafka broker

* Surround `this.kafkaAdmin.clusterId()` call with `Lock`

**Cherry-pick to `3.0.x`**
@sobychacko sobychacko merged commit d982c8e into spring-projects:main Dec 17, 2023
2 checks passed
sobychacko pushed a commit that referenced this pull request Dec 17, 2023
Fixes: #2943

The `if (this.kafkaAdmin != null && this.clusterId == null) {` condition
might be always true for concurrent threads (especially virtual).
Therefore, all of those threads are calling `this.kafkaAdmin.clusterId()`
making unnecessary network chats to Kafka broker

* Surround `this.kafkaAdmin.clusterId()` call with `Lock`

**Cherry-pick to `3.0.x`**
@artembilan artembilan deleted the GH-2943 branch December 18, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix KafkaTemplate.clusterId() for concurrency
2 participants