Skip to content

Commit 23e97a5

Browse files
committed
GH-646: Avoid sync when no transaction
1 parent 1529a42 commit 23e97a5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,13 @@ public void abortTransaction() throws ProducerFencedException {
289289
}
290290

291291
@Override
292-
public synchronized void close() {
293-
if (this.cache != null && !this.cache.contains(this)) {
294-
this.cache.offer(this);
292+
public void close() {
293+
if (this.cache != null) {
294+
synchronized (this) {
295+
if (!this.cache.contains(this)) {
296+
this.cache.offer(this);
297+
}
298+
}
295299
}
296300
}
297301

0 commit comments

Comments
 (0)