JoelWee commented on a change in pull request #8923:
URL: https://github.com/apache/kafka/pull/8923#discussion_r469725796



##########
File path: core/src/main/scala/kafka/tools/StreamsResetter.java
##########
@@ -646,22 +655,68 @@ private boolean isIntermediateTopic(final String topic) {
         return options.valuesOf(intermediateTopicsOption).contains(topic);
     }
 
-    private void maybeDeleteInternalTopics(final Admin adminClient, final 
boolean dryRun) {
-        System.out.println("Deleting all internal/auto-created topics for 
application " + options.valueOf(applicationIdOption));
+    private int maybeDeleteInternalTopics(final Admin adminClient, final 
boolean dryRun) {
+        if (!options.valuesOf(internalTopicsOption).isEmpty()) {
+            return maybeDeleteSpecifiedInternalTopics(adminClient, dryRun);
+        } else {
+            return maybeDeleteInferredInternalTopics(adminClient, dryRun);
+        }
+    }
+
+    private int maybeDeleteSpecifiedInternalTopics(final Admin adminClient, 
final boolean dryRun) {
+        final List<String> internalTopics = 
options.valuesOf(internalTopicsOption);
+        int topicNotFound = EXIT_CODE_SUCCESS;
+
+        final List<String> topicsToDelete = new ArrayList<>();
+        final List<String> notFoundInternalTopics = new ArrayList<>();
+
+        System.out.println("Deleting specified internal/auto-created topics " 
+ internalTopics);
+        for (final String topic : internalTopics) {
+            if (allTopics.contains(topic) && isInferredInternalTopic(topic)) {
+                topicsToDelete.add(topic);
+            } else {
+                notFoundInternalTopics.add(topic);
+            }
+        }
+
+        if (!notFoundInternalTopics.isEmpty()) {

Review comment:
       I would prefer to throw an exception, since it's likely that the user 
has made a mistake. I've implemented this now




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