Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-162

infinite loop in the wrapping code of HelpFormatter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1
    • 1.2
    • Help formatter
    • None

    Description

      If there is not enough space to display a word on a single line, HelpFormatter goes into a infinite loops until the JVM crashes with an OutOfMemoryError.

      Test case:

      Options options = new Options();
      options.addOption("h", "help", false, "This is a looooong description");
      
      HelpFormatter formatter = new HelpFormatter();
      formatter.setWidth(20);
      formatter.printHelp("app", options); // hang & crash
      

      An helpful exception indicating the insufficient width would be more appropriate than an OutOfMemoryError.

      Attachments

        1. CLI-162-additional.patch
          2 kB
          Henri Yandell
        2. CLI-162-take2.patch
          2 kB
          Henri Yandell

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ebourg Emmanuel Bourg
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: