You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2026/05/25 12:28:53 UTC
(pulsar) branch master updated: [fix][test] Fix flaky ProducerCleanupTest timer cleanup (#25864)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 2e02b7830ee [fix][test] Fix flaky ProducerCleanupTest timer cleanup (#25864)
2e02b7830ee is described below
commit 2e02b7830ee14e8d3476dba03f7fa6fd0da175b8
Author: Oneby Wang <44...@users.noreply.github.com>
AuthorDate: Mon May 25 20:28:47 2026 +0800
[fix][test] Fix flaky ProducerCleanupTest timer cleanup (#25864)
---
.../apache/pulsar/client/api/ProducerCleanupTest.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/ProducerCleanupTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/ProducerCleanupTest.java
index 2a7fcb3eb17..09c0113c0a1 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/ProducerCleanupTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/ProducerCleanupTest.java
@@ -20,8 +20,10 @@ package org.apache.pulsar.client.api;
import io.netty.util.HashedWheelTimer;
import java.util.concurrent.TimeUnit;
+import lombok.Cleanup;
import org.apache.pulsar.broker.service.SharedPulsarBaseTest;
import org.apache.pulsar.client.impl.PulsarClientImpl;
+import org.awaitility.Awaitility;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -29,14 +31,17 @@ import org.testng.annotations.Test;
public class ProducerCleanupTest extends SharedPulsarBaseTest {
@Test
- public void testAllTimerTaskShouldCanceledAfterProducerClosed() throws PulsarClientException, InterruptedException {
- Producer<byte[]> producer = pulsarClient.newProducer()
+ public void testAllTimerTaskShouldCanceledAfterProducerClosed() throws PulsarClientException {
+ @Cleanup
+ PulsarClient client = newPulsarClient();
+ Producer<byte[]> producer = client.newProducer()
.topic(newTopicName())
- .sendTimeout(1, TimeUnit.SECONDS)
+ .sendTimeout(15, TimeUnit.SECONDS)
.create();
producer.close();
- Thread.sleep(2000);
- HashedWheelTimer timer = (HashedWheelTimer) ((PulsarClientImpl) pulsarClient).timer();
- Assert.assertEquals(timer.pendingTimeouts(), 0);
+ HashedWheelTimer timer = (HashedWheelTimer) ((PulsarClientImpl) client).timer();
+ Awaitility.await()
+ .atMost(10, TimeUnit.SECONDS)
+ .untilAsserted(() -> Assert.assertEquals(timer.pendingTimeouts(), 0));
}
}