Skip to content

Commit c558d2b

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 4f5a1cf commit c558d2b

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
@@ -334,7 +334,6 @@ public void destroy() {
334334
next = queue.poll();
335335
}
336336
});
337-
this.cache.clear();
338337
synchronized (this.consumerProducers) {
339338
this.consumerProducers.forEach(
340339
(k, v) -> v.getDelegate().close(this.physicalCloseTimeout));

0 commit comments

Comments
 (0)