nodece commented on code in PR #23038: URL: https://github.com/apache/pulsar/pull/23038#discussion_r1687368123
########## pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ClientCnxTest.java: ########## @@ -130,6 +134,50 @@ public void testClientVersion() throws Exception { } @Test + public void testCnxReceiveSendError() throws Exception { + final String topicOne = "persistent://" + NAMESPACE + "/testCnxReceiveSendError-one"; + final String topicTwo = "persistent://" + NAMESPACE + "/testCnxReceiveSendError-two"; + + PulsarClient client = PulsarClient.builder().serviceUrl(lookupUrl.toString()).connectionsPerBroker(1).build(); + Producer<String> producerOne = client.newProducer(Schema.STRING) + .topic(topicOne) + .create(); + Producer<String> producerTwo = client.newProducer(Schema.STRING) + .topic(topicTwo) + .create(); + ClientCnx cnxOne = ((ProducerImpl<?>) producerOne).getClientCnx(); + ClientCnx cnxTwo = ((ProducerImpl<?>) producerTwo).getClientCnx(); + + // simulate a sending error + cnxOne.handleSendError(Commands.newSendErrorCommand(((ProducerImpl<?>) producerOne).producerId, + 10, ServerError.PersistenceError, "persistent error").getSendError()); + + // two producer use the same cnx + Assert.assertEquals(cnxOne, cnxTwo); + + // the cnx will not change + try { + Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> + (((ProducerImpl<?>) producerOne).getClientCnx() != null + && !cnxOne.equals(((ProducerImpl<?>) producerOne).getClientCnx())) + || !cnxTwo.equals(((ProducerImpl<?>) producerTwo).getClientCnx())); + Assert.fail(); + } catch (Throwable e) { + Assert.assertTrue(e instanceof ConditionTimeoutException); + } + + // two producer use the same cnx + Assert.assertEquals(((ProducerImpl<?>) producerTwo).getClientCnx(), + ((ProducerImpl<?>) producerOne).getClientCnx()); Review Comment: It has been merged. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org