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

ijuma 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 066635819a9 MINOR: Improve printing topic name when created topic in 
TopicCommand (#14661)
066635819a9 is described below

commit 066635819a9c59d15616249e93fac43dea797474
Author: runom <[email protected]>
AuthorDate: Mon Nov 20 09:03:07 2023 +0900

    MINOR: Improve printing topic name when created topic in TopicCommand 
(#14661)
    
    The topic name was displayed as `Optional<String>` when the topic was 
created.
    ```
    % bin/kafka-topics.sh --create --topic test --bootstrap-server 
localhost:9092
    Created topic Optional[test].
    ```
    This PR fixed to print the topic name as `String` instead of 
`Optional<String>`.
    ```
    % bin/kafka-topics.sh --create --topic test --bootstrap-server 
localhost:9092
    Created topic test.
    ```
    
    Reviewers: Ismael Juma <[email protected]>
---
 tools/src/main/java/org/apache/kafka/tools/TopicCommand.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/src/main/java/org/apache/kafka/tools/TopicCommand.java 
b/tools/src/main/java/org/apache/kafka/tools/TopicCommand.java
index e490007bd23..ae725012dc1 100644
--- a/tools/src/main/java/org/apache/kafka/tools/TopicCommand.java
+++ b/tools/src/main/java/org/apache/kafka/tools/TopicCommand.java
@@ -247,7 +247,7 @@ public abstract class TopicCommand {
     }
 
     static class CommandTopicPartition {
-        private final Optional<String> name;
+        private final String name;
         private final Optional<Integer> partitions;
         private final Optional<Integer> replicationFactor;
         private final Map<Integer, List<Integer>> replicaAssignment;
@@ -257,7 +257,7 @@ public abstract class TopicCommand {
 
         public CommandTopicPartition(TopicCommandOptions options) {
             opts = options;
-            name = options.topic();
+            name = options.topic().get();
             partitions = options.partitions();
             replicationFactor = options.replicationFactor();
             replicaAssignment = 
options.replicaAssignment().orElse(Collections.emptyMap());
@@ -439,7 +439,7 @@ public abstract class TopicCommand {
 
         public void createTopic(TopicCommandOptions opts) throws Exception {
             CommandTopicPartition topic = new CommandTopicPartition(opts);
-            if (Topic.hasCollisionChars(topic.name.get())) {
+            if (Topic.hasCollisionChars(topic.name)) {
                 System.out.println("WARNING: Due to limitations in metric 
names, topics with a period ('.') or underscore ('_') could " +
                     "collide. To avoid issues it is best to use either, but 
not both.");
             }
@@ -457,9 +457,9 @@ public abstract class TopicCommand {
             try {
                 NewTopic newTopic;
                 if (topic.hasReplicaAssignment()) {
-                    newTopic = new NewTopic(topic.name.get(), 
topic.replicaAssignment);
+                    newTopic = new NewTopic(topic.name, 
topic.replicaAssignment);
                 } else {
-                    newTopic = new NewTopic(topic.name.get(), 
topic.partitions, topic.replicationFactor.map(Integer::shortValue));
+                    newTopic = new NewTopic(topic.name, topic.partitions, 
topic.replicationFactor.map(Integer::shortValue));
                 }
 
                 Map<String, String> configsMap = 
topic.configsToAdd.stringPropertyNames().stream()

Reply via email to