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

infinite loop in the wrapping code of HelpFormatter

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: Help formatter
    • Labels:
      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-take2.patch
          2 kB
          Henri Yandell
        2. CLI-162-additional.patch
          2 kB
          Henri Yandell

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: