commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Lee (JIRA)" <>
Subject [jira] Commented: (CLI-193) StringIndexOutOfBoundsException in HelpFormatter.findWrapPos
Date Tue, 22 Jun 2010 17:46:54 GMT


Chris Lee commented on CLI-193:

Well, that would be easy enough to fix, but that's at odds with how the method is documented
now. It currently says it will ONLY break on a newline or space ("The wrap point is the last
postion before startPos+width having a whitespace character (space, \n, \r).").

In addition to that, it's currently looking for whitespace AFTER startPos+width (also at odds
with documentation). How should it actually behave?

I've attached another patch that will preserve the existing functionality (looking for spaces
after startPos+width) but reverts back to returning startPos+width if none is found.

If, instead, it should *never* allow for a string longer than startPos+width, then current
lines 908-912 should probably just be removed. This will cause "wrap position 3" unit test
to fail though.

> StringIndexOutOfBoundsException in HelpFormatter.findWrapPos
> ------------------------------------------------------------
>                 Key: CLI-193
>                 URL:
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x
>    Affects Versions: 1.2
>            Reporter: Travis McLeskey
>            Priority: Critical
>             Fix For: 1.3
>         Attachments: cli-helpformatter-stringIndexOOB-2.patch, cli-helpformatter-stringIndexOOB.patch
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
> In the last while loop in HelpFormatter.findWrapPos, it can pass text.length() to text.charAt(int),
which throws a StringIndexOutOfBoundsException. The first expression in that while loop condition
should use a <, not a <=.
> This is on line 908 in r779646:

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

View raw message