You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/03/08 18:02:32 UTC

[incubator-pulsar] branch master updated: Fix race in PersistentTopicTest#testClosingReplicationProducerTwice (#1360)

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

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new e35087c  Fix race in PersistentTopicTest#testClosingReplicationProducerTwice (#1360)
e35087c is described below

commit e35087c3d3ec7613060f50f56f5b4975a86d42c3
Author: Ivan Kelly <iv...@apache.org>
AuthorDate: Thu Mar 8 19:02:30 2018 +0100

    Fix race in PersistentTopicTest#testClosingReplicationProducerTwice (#1360)
    
    A race existed where the replicator was making a startProducer call on
    construction before the client was mocked. This startProducer would
    fail on producer creation, which would trigger a backoff and a
    retry. If this fell exactly the wrong way, it could cause
    createProducerAsync to be called multiple times on the mock before the
    check, which would fail the test.
    
    This fix addresses issue #617 and it's duplicate #1145
---
 .../java/org/apache/pulsar/broker/service/PersistentTopicTest.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
index 2f0f350..d6756b4 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
@@ -1205,16 +1205,15 @@ public class PersistentTopicTest {
                 "http://" + pulsar.getAdvertisedAddress() + ":" + pulsar.getConfiguration().getBrokerServicePort());
         PulsarClient client = spy(PulsarClient.builder().serviceUrl(brokerUrl.toString()).build());
         PulsarClientImpl clientImpl = (PulsarClientImpl) client;
+        doReturn(new CompletableFuture<Producer>()).when(clientImpl)
+            .createProducerAsync(any(ProducerConfigurationData.class), any(Schema.class));
 
         ManagedCursor cursor = mock(ManagedCursorImpl.class);
         doReturn(remoteCluster).when(cursor).getName();
         brokerService.getReplicationClients().put(remoteCluster, client);
         PersistentReplicator replicator = new PersistentReplicator(topic, cursor, localCluster, remoteCluster, brokerService);
 
-        doReturn(new CompletableFuture<Producer>()).when(clientImpl)
-                .createProducerAsync(any(ProducerConfigurationData.class));
-
-        replicator.startProducer();
+        // PersistentReplicator constructor calls startProducer()
         verify(clientImpl)
             .createProducerAsync(
                 any(ProducerConfigurationData.class),

-- 
To stop receiving notification emails like this one, please contact
mmerli@apache.org.