soarez commented on code in PR #15605:
URL: https://github.com/apache/kafka/pull/15605#discussion_r1543761783


##########
core/src/test/scala/unit/kafka/coordinator/transaction/ProducerIdManagerTest.scala:
##########
@@ -38,22 +38,32 @@ import org.mockito.Mockito.{mock, when}
 import java.util.concurrent.{CountDownLatch, Executors, TimeUnit}
 import java.util.concurrent.atomic.AtomicBoolean
 import scala.collection.mutable
-import scala.util.{Failure, Success}
+import scala.util.{Failure, Success, Try}
 
 class ProducerIdManagerTest {
 
   var brokerToController: NodeToControllerChannelManager = 
mock(classOf[NodeToControllerChannelManager])
   val zkClient: KafkaZkClient = mock(classOf[KafkaZkClient])
 
+  class ErrorQueue(initialErrorCounts: Errors*) {
+    private val queue: mutable.Queue[Errors] = mutable.Queue.empty ++ 
initialErrorCounts

Review Comment:
   It think this can just be
   
   ```suggestion
       private val queue: mutable.Queue[Errors] = 
mutable.Queue(initialErrorCounts: _*)
   ```



##########
core/src/test/scala/unit/kafka/coordinator/transaction/ProducerIdManagerTest.scala:
##########
@@ -38,22 +38,32 @@ import org.mockito.Mockito.{mock, when}
 import java.util.concurrent.{CountDownLatch, Executors, TimeUnit}
 import java.util.concurrent.atomic.AtomicBoolean
 import scala.collection.mutable
-import scala.util.{Failure, Success}
+import scala.util.{Failure, Success, Try}
 
 class ProducerIdManagerTest {
 
   var brokerToController: NodeToControllerChannelManager = 
mock(classOf[NodeToControllerChannelManager])
   val zkClient: KafkaZkClient = mock(classOf[KafkaZkClient])
 
+  class ErrorQueue(initialErrorCounts: Errors*) {
+    private val queue: mutable.Queue[Errors] = mutable.Queue.empty ++ 
initialErrorCounts
+
+    def takeError(): Errors = queue.synchronized {
+      if (queue.isEmpty) {
+        return Errors.NONE
+      }
+      queue.dequeue()
+    }

Review Comment:
   Now that this class is simple enough, could its use be replaced with 
`java.util.concurrent.ConcurrentLinkedQueue`?



##########
core/src/test/scala/unit/kafka/coordinator/transaction/ProducerIdManagerTest.scala:
##########
@@ -38,22 +38,32 @@ import org.mockito.Mockito.{mock, when}
 import java.util.concurrent.{CountDownLatch, Executors, TimeUnit}
 import java.util.concurrent.atomic.AtomicBoolean
 import scala.collection.mutable
-import scala.util.{Failure, Success}
+import scala.util.{Failure, Success, Try}
 
 class ProducerIdManagerTest {
 
   var brokerToController: NodeToControllerChannelManager = 
mock(classOf[NodeToControllerChannelManager])
   val zkClient: KafkaZkClient = mock(classOf[KafkaZkClient])
 
+  class ErrorQueue(initialErrorCounts: Errors*) {

Review Comment:
   Now that you've removed the error counts, this variable name - 
`initialErrorCounts ` - no longer makes sense.



-- 
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