Skip to content

Commit f715bbe

Browse files
garyrussellartembilan
authored andcommitted
GH-646: Avoid sync when no transaction
1 parent 42e2d01 commit f715bbe

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
@@ -302,9 +302,13 @@ public void abortTransaction() throws ProducerFencedException {
302302
}
303303

304304
@Override
305-
public synchronized void close() {
306-
if (this.cache != null && !this.cache.contains(this)) {
307-
this.cache.offer(this);
305+
public void close() {
306+
if (this.cache != null) {
307+
synchronized (this) {
308+
if (!this.cache.contains(this)) {
309+
this.cache.offer(this);
310+
}
311+
}
308312
}
309313
}
310314

0 commit comments

Comments
 (0)