Commons CLI
  1. Commons CLI
  2. CLI-162

infinite loop in the wrapping code of HelpFormatter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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.

      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:
              Emmanuel Bourg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development