merlimat closed pull request #2595: [tests] Fix the synchronization problem at BrokerClientIntegrationTest.testMaxConcurrentTopicLoading URL: https://github.com/apache/incubator-pulsar/pull/2595
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/BrokerClientIntegrationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/BrokerClientIntegrationTest.java index bf65fdd157..0e47dfe20b 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/BrokerClientIntegrationTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/BrokerClientIntegrationTest.java @@ -583,7 +583,7 @@ public void testMaxConcurrentTopicLoading() throws Exception { ClientCnx cnx = producer.cnx(); assertTrue(cnx.channel().isActive()); ExecutorService executor = Executors.newFixedThreadPool(concurrentLookupRequests); - List<CompletableFuture<Producer<byte[]>>> futures = Lists.newArrayList(); + final List<CompletableFuture<Producer<byte[]>>> futures = Lists.newArrayList(); final int totalProducers = 10; CountDownLatch latch = new CountDownLatch(totalProducers); for (int i = 0; i < totalProducers; i++) { @@ -591,14 +591,18 @@ public void testMaxConcurrentTopicLoading() throws Exception { final String randomTopicName1 = topicName + randomUUID().toString(); final String randomTopicName2 = topicName + randomUUID().toString(); // pass producer-name to avoid exception: producer is already connected to topic - futures.add(pulsarClient2.newProducer().topic(randomTopicName1).createAsync()); - futures.add(pulsarClient.newProducer().topic(randomTopicName2).createAsync()); + synchronized (futures) { + futures.add(pulsarClient2.newProducer().topic(randomTopicName1).createAsync()); + futures.add(pulsarClient.newProducer().topic(randomTopicName2).createAsync()); + } latch.countDown(); }); } latch.await(); - FutureUtil.waitForAll(futures).get(); + synchronized (futures) { + FutureUtil.waitForAll(futures).get(); + } pulsarClient.close(); pulsarClient2.close(); } finally { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services