Issue Details (XML | Word | Printable)

Key: CLI-8
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Teemu Kanstrén
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons CLI

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

Created: 01/Jul/03 04:34 PM   Updated: 15/Sep/08 10:41 PM
Return to search
Component/s: CLI-1.x
Affects Version/s: 1.0
Fix Version/s: 1.1

Time Tracking:
Not Specified

Environment:
Operating System: All
Platform: PC
Issue Links:
Duplicate
 

Bugzilla Id: 21215


 Description  « Hide
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


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Rob Oxspring added a comment - 27/Dec/04 11:53 PM
Added test to BugsTest and fixed in CVS
The bug also applied to the header text but would have affected other strings
starting with line separators,

Rob