lhotari commented on code in PR #18635:
URL: https://github.com/apache/pulsar/pull/18635#discussion_r1032588940
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v3/AdminApiTransactionTest.java:
##########
@@ -624,8 +624,9 @@ public void testUpdateTransactionCoordinatorNumber() throws
Exception {
}
admin.transactions().scaleTransactionCoordinators(coordinatorSize * 2);
- pulsarClient =
PulsarClient.builder().serviceUrl(lookupUrl.toString()).enableTransaction(true).build();
+
replacePulsarClient(PulsarClient.builder().serviceUrl(lookupUrl.toString()).enableTransaction(true));
pulsarClient.close();
Review Comment:
@tisonkun I checked again and it's pretty clear what it does. If you remove
the lines of code you will notice the impact.
This is from the initTransaction method:
```java
replacePulsarClient(PulsarClient.builder().serviceUrl(lookupUrl.toString()).enableTransaction(true));
pulsarClient.close();
pulsarClient = null;
Awaitility.await().until(() ->
pulsar.getTransactionMetadataStoreService().getStores().size() ==
coordinatorSize);
replacePulsarClient(PulsarClient.builder().serviceUrl(lookupUrl.toString()).enableTransaction(true));
```
It will first close the existing pulsarClient instance and replace it with a
pulsarClient instance that has transaction coordination client enabled. The
side-effect of the client connecting to the broker will initiate the required
services in the broker. I don't know the exact reason to close the client and
then create a new client, but that's how it is. It's not a part of this PR to
start refactoring the test code beyond the purpose of fixing the Pulsar client
leaks.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]