apoorvmittal10 commented on code in PR #19640:
URL: https://github.com/apache/kafka/pull/19640#discussion_r2076271559


##########
core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala:
##########
@@ -147,7 +147,9 @@ class GroupCoordinatorBaseRequestTest(cluster: 
ClusterInstance) {
   protected def closeSockets(): Unit = {
     while (openSockets.nonEmpty) {
       val socket = openSockets.head
-      socket.close()
+      if (!socket.isClosed) {
+        socket.close()
+      }

Review Comment:
   Seems strange that we are fetching from `openSockets` and checking if it's 
closed. So if it was `closed` then why not removed.



##########
core/src/test/scala/unit/kafka/server/ShareFetchAcknowledgeRequestTest.scala:
##########
@@ -59,11 +59,15 @@ class ShareFetchAcknowledgeRequestTest(cluster: 
ClusterInstance) extends GroupCo
       new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("topic1", 1))
     )
 
+    val socket: Socket = createSocket()
+
     val shareFetchRequest = createShareFetchRequest(groupId, metadata, send, 
Seq.empty, Map.empty)
-    val shareFetchResponse = 
connectAndReceiveWithoutClosingSocket[ShareFetchResponse](shareFetchRequest)
+    val shareFetchResponse = 
sendAndReceiveFromExistingSocket[ShareFetchResponse](shareFetchRequest, socket)
 
     assertEquals(Errors.UNSUPPORTED_VERSION.code, 
shareFetchResponse.data.errorCode)
     assertEquals(0, shareFetchResponse.data.acquisitionLockTimeoutMs)
+
+    socket.close()

Review Comment:
   So if we avoid this call here and rely on `tearDown` to close sockets then 
will it cause any trouble? Then you don't need to have an explicit `if 
(!socket.isClosed)` as well?



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

Reply via email to