commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Bourg (JIRA)" <j...@apache.org>
Subject [jira] Updated: (CLI-8) Line separator as first char for helpformatter (footer) throws exception
Date Mon, 15 Sep 2008 22:41:44 GMT

     [ https://issues.apache.org/jira/browse/CLI-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Emmanuel Bourg updated CLI-8:
-----------------------------

    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

{code:java}
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);
  }
}
{code}

result is:

{code}
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
{code}

  was:
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

        Summary: Line separator as first char for helpformatter (footer) throws exception
 (was: [cli] Line separator as first char for helpformatter (footer) throws exception)

> Line separator as first char for helpformatter (footer) throws exception
> ------------------------------------------------------------------------
>
>                 Key: CLI-8
>                 URL: https://issues.apache.org/jira/browse/CLI-8
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x
>    Affects Versions: 1.0
>         Environment: Operating System: All
> Platform: PC
>            Reporter: Teemu Kanstrén
>             Fix For: 1.1
>
>
> 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
> {code:java}
> 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);
>   }
> }
> {code}
> result is:
> {code}
> 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
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message