leaf-soba commented on code in PR #18926: URL: https://github.com/apache/kafka/pull/18926#discussion_r1976937260
########## raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java: ########## @@ -359,7 +356,10 @@ public void testInitializeAsResignedLeaderFromStateStore(boolean withKip853Rpc) assertEquals(0L, context.log.endOffset().offset()); context.assertElectedLeader(epoch, localId); context.client.poll(); - assertThrows(NotLeaderException.class, () -> context.client.prepareAppend(epoch, Arrays.asList("a", "b"))); + // Only one method invocation is expected when testing runtime exceptions Review Comment: Thank you for your comment. the original code: ``` assertThrows(NotLeaderException.class, () -> context.client.prepareAppend(epoch, Arrays.asList("a", "b"))); ``` In this case, there are two method calls inside `assertThrows`: 1. `prepareAppend` 2. `Arrays.asList` I believe it’s generally a good practice to keep the tested code as clear as possible by avoiding multiple method calls within `assertThrows`. While `Arrays.asList` would never throw a `NotLeaderException`, separating it slightly improves the readability of the test. I understand if this change is unnecessary. Please let me know if you’d prefer me to revert it. -- 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