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

Line separator as first char for helpformatter (footer) throws exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1
    • CLI-1.x
    • None
    • Operating System: All
      Platform: PC

    • 21215

    Description

      This might apply for more than just the footer. I only tested footer so don't
      know.

      compile and run this example and you will get an exception

      public class CliError
      {
        public static void main(String[] args)
        {
          Options options = new Options();
          HelpFormatter formatter = new HelpFormatter();
          String footer = System.getProperty("line.separator")+"Hello world.";
          formatter.printHelp(80, "foobar", "", options, footer, true);
        }
      }
      

      result is:

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.charAt(String.java:582)
      	at org.apache.commons.cli.HelpFormatter.rtrim(HelpFormatter.java:505)
      	at org.apache.commons.cli.HelpFormatter.renderWrappedText(HelpFormatter.java:416)
      	at org.apache.commons.cli.HelpFormatter.printWrapped(HelpFormatter.java:324)
      	at org.apache.commons.cli.HelpFormatter.printWrapped(HelpFormatter.java:318)
      	at org.apache.commons.cli.HelpFormatter.printHelp(HelpFormatter.java:212)
      	at org.apache.commons.cli.HelpFormatter.printHelp(HelpFormatter.java:165)
      	at com.nokia.em.bts.swupdateautomate.test.CliError.main(CliError.java:21)
      
      Exception in thread "main" Process terminated with exit code 1
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kibaltsis@hotmail.com Teemu Kanstrén
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: