You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by mi...@apache.org on 2023/07/28 09:45:22 UTC

[kafka] branch trunk updated: KAFKA-14967: fix NPE in CreateTopicsResult in MockAdminClient (#13671)

This is an automated email from the ASF dual-hosted git repository.

mimaison pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new afe631cd736 KAFKA-14967: fix NPE in CreateTopicsResult in MockAdminClient (#13671)
afe631cd736 is described below

commit afe631cd7362222dec08463fed509fe24e43b5e7
Author: James Shaw <js...@zepler.net>
AuthorDate: Fri Jul 28 10:45:15 2023 +0100

    KAFKA-14967: fix NPE in CreateTopicsResult in MockAdminClient (#13671)
    
    
    Co-authored-by: James Shaw <ja...@masabi.com>
    Reviewers: Mickael Maison <mi...@gmail.com>
---
 .../java/org/apache/kafka/clients/admin/MockAdminClient.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java b/clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java
index 7da22cc787d..3d43d75d1d2 100644
--- a/clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java
+++ b/clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java
@@ -391,13 +391,23 @@ public class MockAdminClient extends AdminClient {
             topicIds.put(topicName, topicId);
             topicNames.put(topicId, topicName);
             allTopics.put(topicName, new TopicMetadata(topicId, false, partitions, logDirs, newTopic.configs()));
-            future.complete(null);
+            future.complete(new CreateTopicsResult.TopicMetadataAndConfig(topicId, numberOfPartitions, replicationFactor, config(newTopic)));
             createTopicResult.put(topicName, future);
         }
 
         return new CreateTopicsResult(createTopicResult);
     }
 
+    private static Config config(NewTopic newTopic) {
+        Collection<ConfigEntry> configEntries = new ArrayList<>();
+        if (newTopic.configs() != null) {
+            for (Map.Entry<String, String> entry : newTopic.configs().entrySet()) {
+                configEntries.add(new ConfigEntry(entry.getKey(), entry.getValue()));
+            }
+        }
+        return new Config(configEntries);
+    }
+
     @Override
     synchronized public ListTopicsResult listTopics(ListTopicsOptions options) {
         Map<String, TopicListing> topicListings = new HashMap<>();