You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Kirk True (Jira)" <ji...@apache.org> on 2021/07/06 01:27:00 UTC
[jira] [Comment Edited] (KAFKA-12989) MockClient should respect the
request matcher passed to prepareUnsupportedVersionResponse
[ https://issues.apache.org/jira/browse/KAFKA-12989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17375090#comment-17375090 ]
Kirk True edited comment on KAFKA-12989 at 7/6/21, 1:26 AM:
------------------------------------------------------------
I don't really understand the purpose of {{RequestMatcher}}, because a quick glance at the code appears to show that it's never used for the negative test case. If, in fact, the code ever does return {{false}} from the {{matches}} method (even for {{prepare*}} methods), an {{IllegalStateException}} is thrown internally:
{code:java}
java.lang.IllegalStateException: Request matcher did not match next-in-line request DescribeClusterRequestData(includeClusterAuthorizedOperations=false) with prepared response null
at org.apache.kafka.clients.MockClient.send(MockClient.java:250)
at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.sendEligibleCalls(KafkaAdminClient.java:1164)
at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.processRequests(KafkaAdminClient.java:1377)
at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.run(KafkaAdminClient.java:1320)
at java.lang.Thread.run(Thread.java:748)
{code}
The test then just hangs there until this error is shown:
{noformat}
testMatchesReturnsFalse() timed out after 120 seconds.
{noformat}
was (Author: kirktrue):
I don't really understand the purpose of {{RequestMatcher}}, because a quick glance at the code appears to show that it's never used for the negative test case. If, in fact, the code ever does return {{false}} from the {{matches}} method (even for {{prepare*}} methods), an {{IllegalStateException}} is thrown and the client thread is exited but the test code just hangs there for two minutes.
{code:java}
java.lang.IllegalStateException: Request matcher did not match next-in-line request DescribeClusterRequestData(includeClusterAuthorizedOperations=false) with prepared response nulljava.lang.IllegalStateException: Request matcher did not match next-in-line request DescribeClusterRequestData(includeClusterAuthorizedOperations=false) with prepared response null
at org.apache.kafka.clients.MockClient.send(MockClient.java:250) at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.sendEligibleCalls(KafkaAdminClient.java:1164) at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.processRequests(KafkaAdminClient.java:1377) at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.run(KafkaAdminClient.java:1320) at java.lang.Thread.run(Thread.java:748)
{code}
> MockClient should respect the request matcher passed to prepareUnsupportedVersionResponse
> -----------------------------------------------------------------------------------------
>
> Key: KAFKA-12989
> URL: https://issues.apache.org/jira/browse/KAFKA-12989
> Project: Kafka
> Issue Type: Bug
> Reporter: David Jacot
> Priority: Major
>
> The {{MockClient}} offers the possibility to prepare an unsupported version response with {{MockClient#prepareUnsupportedVersionResponse}}. That method accepts a {{RequestMatcher}} but it is never applied. It should be or we should remove the matcher from the method.
> {code:java}
> UnsupportedVersionException unsupportedVersionException = null;
> if (futureResp.isUnsupportedRequest) {
> unsupportedVersionException = new UnsupportedVersionException(
> "Api " + request.apiKey() + " with version " + version);
> } else {
> AbstractRequest abstractRequest = request.requestBuilder().build(version);
> if (!futureResp.requestMatcher.matches(abstractRequest))
> throw new IllegalStateException("Request matcher did not match next-in-line request "
> + abstractRequest + " with prepared response " + futureResp.responseBody);
> }
> ClientResponse resp = new ClientResponse(request.makeHeader(version), request.callback(), request.destination(),
> request.createdTimeMs(), time.milliseconds(), futureResp.disconnected,
> unsupportedVersionException, null, futureResp.responseBody);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)