Greg Harris created KAFKA-16421:
-----------------------------------
Summary: Refactor CommandDefaultOptions subclasses to throw
exceptions instead of calling exit.
Key: KAFKA-16421
URL: https://issues.apache.org/jira/browse/KAFKA-16421
Project: Kafka
Issue Type: Wish
Components: tools
Reporter: Greg Harris
Many command-line utilities use the "mainNoExit()" idiom to provide a testable
entrypoint to the command-line utility that doesn't include calling
System.exit. This allows tests to safely exercise the command-line utility
end-to-end, without risk that the JVM will stop.
Often, command implementations themselves adhere to this idiom, and don't call
Exit. However, this is compromised by the CommandLineUtils functions, which
call Exit.exit when an error is encountered while parsing the command-line
arguments.
These utilities are pervasively used in subclasses of CommandDefaultOptions,
across hundreds of call-sites. We should figure out a way to replace this exit
behavior with exceptions that are eventually propagated from the *Options
constructors. This will allow the command-line implementations to handle these
errors, and return the appropriate exit code from mainNoExit.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)