MINOR: Closing consumerGroupService resources in SaslClientsWithInvalidCredentialsTest
Reviewers: Manikumar Reddy
@@ -161,10 +161,11 @@ class SaslClientsWithInvalidCredentialsTest extends IntegrationTestHarness with
val consumerGroupService: ConsumerGroupService = prepareConsumerGroupService
val consumer = createConsumer()
+ try {
consumer.subscribe(List(topic).asJava)
verifyAuthenticationException(consumerGroupService.listGroups())
- consumerGroupService.close()
+ } finally consumerGroupService.close()
}
@Test
@@ -173,19 +174,23 @@ class SaslClientsWithInvalidCredentialsTest extends IntegrationTestHarness with
val consumerGroupService: ConsumerGroupService = prepareConsumerGroupService
val consumer = createConsumer()
+ try {
consumer.subscribe(List(topic).asJava)
verifyWithRetry(consumer.poll(Duration.ofMillis(1000)))
assertEquals(1, consumerGroupService.listConsumerGroups().size)
- consumerGroupService.close()
+ }
+ finally consumerGroupService.close()
}
private def prepareConsumerGroupService = {
val propsFile = TestUtils.tempFile()
val propsStream = Files.newOutputStream(propsFile.toPath)
+ try {
propsStream.write("security.protocol=SASL_PLAINTEXT\n".getBytes())
propsStream.write(s"sasl.mechanism=$kafkaClientSaslMechanism".getBytes())
- propsStream.close()
+ }
+ finally propsStream.close()
val cgcArgs = Array("--bootstrap-server", brokerList,
"--describe",
