Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-16421

Refactor CommandDefaultOptions subclasses to throw exceptions instead of calling exit.

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • tools
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gharris1727 Greg Harris
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: