This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit a4e111979c2b086526536cf00223725fe5e7981c
Author: Lari Hotari <[email protected]>
AuthorDate: Thu Apr 9 01:39:36 2026 +0300

    [fix][test] Fix flaky 
ServerCnxTest.testCreateProducerTimeoutThenCreateSameNamedProducerShouldFail 
(#25497)
    
    (cherry picked from commit 7ce8a8c7a03b2cef1360d05f918436c84d7627fe)
---
 .../test/java/org/apache/pulsar/broker/service/ServerCnxTest.java  | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
index bb4b8bbf0e5..824bfca9c20 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
@@ -2135,6 +2135,13 @@ public class ServerCnxTest {
                 producerName, Collections.emptyMap(), false);
         channel.writeInbound(createProducer1);
 
+        // Run pending tasks to ensure the producer is registered in the 
producers map
+        // before the close command is processed. Without this, the close 
command may not
+        // find the producer (since registration happens in a thenApplyAsync 
callback),
+        // causing it to skip cancellation and leading to a race between the 
first and
+        // second producer creation.
+        channel.runPendingTasks();
+
         ByteBuf closeProducer = Commands.newCloseProducer(1 /* producer id */, 
2 /* request id */);
         channel.writeInbound(closeProducer);
 

Reply via email to