You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "joshua2519 (via GitHub)" <gi...@apache.org> on 2026/03/31 09:43:12 UTC
[PR] KAFKA-20078: Fix DumpLogSegments to return proper exit codes [kafka]
joshua2519 opened a new pull request, #21907:
URL: https://github.com/apache/kafka/pull/21907
- Add mainNoExit pattern (matching other Kafka CLI tools like GetOffsetShell) so main returns exit code 0 on success and 1 on failure via Exit.exit()
- dumpProducerIdSnapshot: rethrow CorruptSnapshotException as TerseException instead of silently printing to stderr
- dumpTxnIndex: catch CorruptIndexException | KafkaException and rethrow as TerseException
- execute now throws TerseException when index mismatches, time index errors, or non-consecutive offsets are detected
- Update tests to use mainNoExit and assert exit codes instead of catching thrown exceptions
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20078: Remove `Exit.exit` from `tools` [kafka]
Posted by "joshua2519 (via GitHub)" <gi...@apache.org>.
joshua2519 commented on code in PR #21907:
URL: https://github.com/apache/kafka/pull/21907#discussion_r3394648332
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:
##########
@@ -66,13 +67,17 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import joptsimple.OptionException;
public class ShareGroupCommand {
static final String MISSING_COLUMN_VALUE = "-";
public static void main(String[] args) {
+ Exit.exit(mainNoExit(args));
+ }
+
+ static int mainNoExit(String[] args) {
+ int exitCode = 0;
ShareGroupCommandOptions opts = new ShareGroupCommandOptions(args);
Review Comment:
Done
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20078: Fix exit codes in CLI tools using mainNoExit pattern [kafka]
Posted by "joshua2519 (via GitHub)" <gi...@apache.org>.
joshua2519 commented on code in PR #21907:
URL: https://github.com/apache/kafka/pull/21907#discussion_r3212230168
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:
##########
@@ -203,7 +204,12 @@ private ConsumerGroupCommandOptions(String[] args) {
resetToDatetimeOpt, resetByDurationOpt, resetToEarliestOpt, resetToLatestOpt, resetToCurrentOpt, resetFromFileOpt);
allDeleteOffsetsOpts = Set.of(groupOpt, topicOpt);
- options = parser.parse(args);
+ try {
+ options = parser.parse(args);
+ } catch (OptionException e) {
+ CommandLineUtils.printUsageAndExit(parser, e.getMessage());
Review Comment:
Yes! I'd like to fix this in this PR by removing Exit.exit from printUsageAndExit entirely — Exit.exit should only live in main. Heads up that this will expand the diff since printUsageAndExit is called from many tools and from sibling helpers inside CommandLineUtils, but I think it's worth keeping the cleanup in one PR.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20078: Fix exit codes in CLI tools using mainNoExit pattern [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #21907:
URL: https://github.com/apache/kafka/pull/21907#discussion_r3155156847
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommand.java:
##########
@@ -74,14 +75,18 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import joptsimple.OptionException;
import joptsimple.OptionSpec;
public class ConsumerGroupCommand {
static final String MISSING_COLUMN_VALUE = "-";
public static void main(String[] args) {
+ Exit.exit(mainNoExit(args));
+ }
+
+ static int mainNoExit(String[] args) {
+ int exitCode = 0;
ConsumerGroupCommandOptions opts = ConsumerGroupCommandOptions.fromArgs(args);
Review Comment:
Should `ConsumerGroupCommandOptions opts = ConsumerGroupCommandOptions.fromArgs(args);` be inside the try-catch block?
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ShareGroupCommand.java:
##########
@@ -66,13 +67,17 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import joptsimple.OptionException;
public class ShareGroupCommand {
static final String MISSING_COLUMN_VALUE = "-";
public static void main(String[] args) {
+ Exit.exit(mainNoExit(args));
+ }
+
+ static int mainNoExit(String[] args) {
+ int exitCode = 0;
ShareGroupCommandOptions opts = new ShareGroupCommandOptions(args);
Review Comment:
Should `ShareGroupCommandOptions opts = new ShareGroupCommandOptions(args);` be inside the try-catch block?
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20078: Fix exit codes in CLI tools using mainNoExit pattern [kafka]
Posted by "joshua2519 (via GitHub)" <gi...@apache.org>.
joshua2519 commented on PR #21907:
URL: https://github.com/apache/kafka/pull/21907#issuecomment-4301606888
> m1a2st
Thanks @m1a2st for the review! I've updated all five tools and the scope of this PR.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20078: Fix exit codes in CLI tools using mainNoExit pattern [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #21907:
URL: https://github.com/apache/kafka/pull/21907#discussion_r3142320925
##########
tools/src/main/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandOptions.java:
##########
@@ -203,7 +204,12 @@ private ConsumerGroupCommandOptions(String[] args) {
resetToDatetimeOpt, resetByDurationOpt, resetToEarliestOpt, resetToLatestOpt, resetToCurrentOpt, resetFromFileOpt);
allDeleteOffsetsOpts = Set.of(groupOpt, topicOpt);
- options = parser.parse(args);
+ try {
+ options = parser.parse(args);
+ } catch (OptionException e) {
+ CommandLineUtils.printUsageAndExit(parser, e.getMessage());
Review Comment:
`printUsageAndExit` still uses `exit`, right?
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org