m1a2st commented on code in PR #16019:
URL: https://github.com/apache/kafka/pull/16019#discussion_r1685761154


##########
tools/src/test/java/org/apache/kafka/tools/consumer/ConsoleConsumerTest.java:
##########
@@ -239,4 +284,73 @@ public void shouldWorkWithoutTopicOption() throws 
IOException {
         verify(mockConsumer).subscribe(any(Pattern.class));
         consumer.cleanup();
     }
+
+    @ClusterTest(brokers = 3)
+    public void testTransactionLogMessageFormatter(ClusterInstance cluster) 
throws Exception {
+        try (Admin admin = cluster.createAdminClient()) {
+
+            NewTopic newTopic = new NewTopic(topic, 1, (short) 1);
+            admin.createTopics(singleton(newTopic));
+            produceMessages(cluster);
+
+            String[] transactionLogMessageFormatter = new String[]{
+                "--bootstrap-server", cluster.bootstrapServers(),
+                "--topic", Topic.TRANSACTION_STATE_TOPIC_NAME,
+                "--formatter", 
"org.apache.kafka.tools.consumer.TransactionLogMessageFormatter",
+                "--from-beginning"
+            };
+
+            ConsoleConsumerOptions options = new 
ConsoleConsumerOptions(transactionLogMessageFormatter);
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            PrintStream output = new PrintStream(out);
+            ConsoleConsumer.process(1, options.formatter(),

Review Comment:
   Thanks for your comments, I will use try catch block to close these resources



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to