Skip to content

Commit

Permalink
remove synchronized
Browse files Browse the repository at this point in the history
  • Loading branch information
wooEnrico committed Jun 25, 2024
1 parent d921a43 commit 222906b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,14 @@ public void close() {
this.threadPoolExecutor.shutdown();
}

private synchronized void subscribe(org.apache.kafka.clients.consumer.KafkaConsumer<K, V> kafkaConsumer) {
private void subscribe(org.apache.kafka.clients.consumer.KafkaConsumer<K, V> kafkaConsumer) {
if (kafkaConsumer != null) {
CompletableFuture<Void> remove = this.consumerMap.remove(kafkaConsumer);
// kafka close is not thread-safe must call by poll thread
CompletableFuture.runAsync(kafkaConsumer::close, this.pollExecutor);
if (remove == null) {
return;
}

try {
Thread.sleep(0);
} catch (InterruptedException ignored) {
}
// kafka close is not thread-safe must call by poll thread
CompletableFuture.runAsync(kafkaConsumer::close, this.pollExecutor);
}

if (this.close.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void close() throws IOException {
this.threadPoolExecutor.shutdown();
}

private synchronized void subscribe(KafkaReceiver<K, V> kafkaReceiver) {
private void subscribe(KafkaReceiver<K, V> kafkaReceiver) {
if (kafkaReceiver != null) {
Disposable remove = this.subscribers.remove(kafkaReceiver);
if (remove == null) {
Expand Down

0 comments on commit 222906b

Please sign in to comment.