chia7712 commented on a change in pull request #10465:
URL: https://github.com/apache/kafka/pull/10465#discussion_r608328844



##########
File path: core/src/test/java/kafka/test/MockController.java
##########
@@ -77,8 +82,28 @@ private MockController(Collection<MockTopic> initialTopics) {
     }
 
     @Override
-    public CompletableFuture<CreateTopicsResponseData> 
createTopics(CreateTopicsRequestData request) {
-        throw new UnsupportedOperationException();
+    synchronized public CompletableFuture<CreateTopicsResponseData>
+            createTopics(CreateTopicsRequestData request) {
+        CreateTopicsResponseData response = new CreateTopicsResponseData();
+        for (CreatableTopic topic : request.topics()) {
+            if (topicNameToId.containsKey(topic.name())) {
+                response.topics().add(new CreatableTopicResult().
+                    setName(topic.name()).
+                    setErrorCode(Errors.TOPIC_ALREADY_EXISTS.code()));
+            } else {
+                long topicId = nextTopicId.getAndAdd(1);

Review comment:
       How about using `getAndIncrement`?




-- 
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:
us...@infra.apache.org


Reply via email to