chia7712 commented on code in PR #16753:
URL: https://github.com/apache/kafka/pull/16753#discussion_r1703356106
##########
clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java:
##########
@@ -7811,6 +7816,40 @@ public void testListClientMetricsResourcesNotSupported()
{
}
}
+ @Test
+ public void
testCallFailWithUnsupportedVersionExceptionDoesNotHaveConcurrentModificationException()
throws InterruptedException {
+ try (AdminClientUnitTestEnv env = new
AdminClientUnitTestEnv(mockCluster(1, 0))) {
+ AdminMetadataManager metadataManager =
mock(AdminMetadataManager.class);
+
+ // first false result make sure
LeastLoadedBrokerOrActiveKController#provide can go to requestUpdate
+ // second true result make sure
LeastLoadedBrokerOrActiveKController#provide can get a node
+ doReturn(false).doReturn(true).when(metadataManager).isReady();
+
+ // make maybeDrainPendingCall throw UnsupportedVersionException
and go to Call#fail
+ doThrow(new UnsupportedVersionException("Unsupported
version")).doNothing().when(metadataManager).requestUpdate();
+
+ // make sure describeCluster handleUnsupportedVersionException
doesn't always return false
+ doReturn(false).when(metadataManager).usingBootstrapControllers();
+ // avoid sending fetchMetadata request
+ doReturn(1L).when(metadataManager).metadataFetchDelayMs(anyLong());
+
+ env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
+
+ try (KafkaAdminClient admin = KafkaAdminClient.createInternal(
Review Comment:
you do close manually, so this try-resource can be removed, right?
--
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]