diff --git a/clients/src/test/java/org/apache/kafka/clients/MockClient.java b/clients/src/test/java/org/apache/kafka/clients/MockClient.java index 1f626435c13e4..eaf5dcb4f8fd1 100644 --- a/clients/src/test/java/org/apache/kafka/clients/MockClient.java +++ b/clients/src/test/java/org/apache/kafka/clients/MockClient.java @@ -44,12 +44,7 @@ * A mock network client for use testing code */ public class MockClient implements KafkaClient { - public static final RequestMatcher ALWAYS_TRUE = new RequestMatcher() { - @Override - public boolean matches(AbstractRequest body) { - return true; - } - }; + public static final RequestMatcher ALWAYS_TRUE = body -> true; private static class FutureResponse { private final Node node; diff --git a/clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java b/clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java index 14f39a984f838..f672918eac201 100644 --- a/clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java +++ b/clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java @@ -767,7 +767,11 @@ public void testInitTransactionTimeout() { assertThrows(TimeoutException.class, producer::initTransactions); - client.respond(FindCoordinatorResponse.prepareResponse(Errors.NONE, host1)); + client.prepareResponse( + request -> request instanceof FindCoordinatorRequest && + ((FindCoordinatorRequest) request).data().keyType() == FindCoordinatorRequest.CoordinatorType.TRANSACTION.id(), + FindCoordinatorResponse.prepareResponse(Errors.NONE, host1)); + client.prepareResponse(initProducerIdResponse(1L, (short) 5, Errors.NONE)); // retry initialization should work