Skip to content

Commit e815ace

Browse files
garyrussellartembilan
authored andcommitted
GH-1613: Fix Race in Producer Factory
Resolves #1613 Do not clear the cache in `destroy()` - just drain the producer queues instead. Fixes a race condition where a producer could be returned to the cache between draining the queues and clearing the map. Just leave the queue(s) in place to accept new returns. **cherry-pick to 2.5.x, 2.4.x, 2.3.x, 1.3.x** (cherry picked from commit 7ad38c0)
1 parent fb1977c commit e815ace

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ public void destroy() {
438438
next = queue.poll();
439439
}
440440
});
441-
this.cache.clear();
442441
synchronized (this.consumerProducers) {
443442
this.consumerProducers.forEach(
444443
(k, v) -> v.closeDelegate(this.physicalCloseTimeout, this.listeners));

0 commit comments

Comments
 (0)