chia7712 commented on code in PR #18989:
URL: https://github.com/apache/kafka/pull/18989#discussion_r1970705554


##########
core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala:
##########
@@ -561,5 +568,17 @@ abstract class EndToEndAuthorizationTest extends 
IntegrationTestHarness with Sas
       case _: TopicAuthorizationException => consumeRecords(consumer, 
numRecords, startingOffset, topic)
     }
   }
+
+  // Consume records, ignoring TopicAuthorization exception from previously 
sent request.
+  private def consumeRecordsIgnoreAuthorizationException(consumer: 
Consumer[Array[Byte], Array[Byte]],
+    numRecords: Int = 1,
+    startingOffset: Int = 0,
+    topic: String = topic): Unit = {
+    try {
+      consumeRecords(consumer, numRecords, startingOffset, topic)
+    } catch {
+      case _: TopicAuthorizationException => 
consumeRecordsIgnoreAuthorizationException(consumer, numRecords, 
startingOffset, topic)

Review Comment:
   Is this recursive call necessary? TestUtils.waitUntilTrue already contains a 
loop, so perhaps we can streamline the check as follows:
   
   ```
         TestUtils.waitUntilTrue(() => {
           try {
             consumeRecords(consumer)
             true
           } catch {
             case _: TopicAuthorizationException => false
           }
         }, "Consumer didn't manage to consume the records within timeout.")
   ```



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to