acsaki commented on code in PR #12179:
URL: https://github.com/apache/kafka/pull/12179#discussion_r888821809


##########
clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java:
##########
@@ -781,14 +781,13 @@ public void testConnectDisconnectDuringInSinglePoll() 
throws Exception {
         when(kafkaChannel.selectionKey()).thenReturn(selectionKey);
         when(selectionKey.channel()).thenReturn(SocketChannel.open());
         when(selectionKey.readyOps()).thenReturn(SelectionKey.OP_CONNECT);
+        when(selectionKey.attachment()).thenReturn(kafkaChannel);
 
-        selectionKey.attach(kafkaChannel);
         Set<SelectionKey> selectionKeys = Utils.mkSet(selectionKey);
         selector.pollSelectionKeys(selectionKeys, false, System.nanoTime());
 
         assertFalse(selector.connected().contains(kafkaChannel.id()));
         assertTrue(selector.disconnected().containsKey(kafkaChannel.id()));
-        assertNull(selectionKey.attachment());

Review Comment:
   This test failed after my change to use mockitoInline to mock statics. The 
`selectionKey.attach` line called the mock's method directly (pointless?) while 
it looked like the actual intention was `selectionKey.attachment()` to return 
the kafkaChannel. That's how it worked actually. Calling the mock method 
directly in the test and later asserting on attachment being null seemed 
confusing to me and the assert actually fails too. (with #attachment returning 
the kafkaChannel). Maybe this was sort of overbearing, is there a simpler way 
to fix the test?



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