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

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

commit 077bebdb5bbf7e97406f81481386b99acd61f3ef
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 90039019b13..24c288d6243 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
@@ -2139,6 +2139,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