[ 
https://issues.apache.org/jira/browse/KAFKA-9631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17075896#comment-17075896
 ] 

ASF GitHub Bot commented on KAFKA-9631:
---------------------------------------

efgpinto commented on pull request #8430: KAFKA-9631: Fix support for optional 
fields in MockAdminClient
URL: https://github.com/apache/kafka/pull/8430
 
 
   AdminClient's createTopics() method has a variant with two optional fields. 
However, using those two fields as empty would cause the MockAdminClient to 
throw an Exception while attempting to create a list with size -1. This PR 
fixes that by defaulting the value to 0 when those values are not passed.
   
   ### Committer Checklist (excluded from commit message)
   - [x] Verify design and implementation 
   - [x] Verify test coverage and CI build status
   - [x] Verify documentation (including upgrade notes)
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> MockAdminClient doesn't handle CreateTopics optional fields
> -----------------------------------------------------------
>
>                 Key: KAFKA-9631
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9631
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Gwen Shapira
>            Priority: Major
>
> AdminClient's {{createTopics()}} method has a variant with two optional 
> fields. So I'd expect the following code to work correctly:
>  {{admin.createTopics(Collections.singletonList(new NewTopic(TOPIC_NAME, 
> Optional.empty(), Optional.empty())))}}
> Indeed it works great, as long as we are using the real KafkaAdminClient. 
> MockKafkaAdminClient tries to get number of replicas without checking that 
> the values make sense , and therefore it fails with:
> {{java.lang.IllegalArgumentException: Illegal Capacity: -1}}{{at 
> java.base/java.util.ArrayList.<init>(ArrayList.java:158)}}
> {{ at 
> org.apache.kafka.clients.admin.MockAdminClient.createTopics(MockAdminClient.java:183)}}
> {{ at org.apache.kafka.clients.admin.Admin.createTopics(Admin.java:125)}}
> Making a mockery of the mock.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to