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

Paul King resolved GROOVY-6991.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 2.5.0-beta-1
         Assignee: Paul King

This appears to be fixed with Commons CLI 1.3:
{code}
def cli = new CliBuilder()
cli.header = 'x' * cli.width
cli.usage()
cli.header = 'x' * (cli.width * 20)
cli.usage()  // no SIOBE and prints 20 lines of x's
{code}

> CliBuilder.usage() fails with SIOBE if header/footer longer than 74 chars
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-6991
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6991
>             Project: Groovy
>          Issue Type: Bug
>          Components: command line processing
>    Affects Versions: 2.4.1
>            Reporter: Rafael Chaves
>            Assignee: Paul King
>             Fix For: 2.5.0-beta-1
>
>
> Have a CliBuilder, set a string longer that HelpFormatter.DEFAULT_WIDTH, and 
> try to show usage.
> {code}
>               CliBuilder cli = new CliBuilder()
>               cli.header = (1..cli.width).collect{'x'}.join()
>               cli.usage()
>               cli.header = (1..cli.width+1).collect{'x'}.join()
>               cli.usage() // SIOBE
> {code}
> Result is:
> {code}
> usage: groovy
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String 
> index out of range: 75
>       at java.lang.String.charAt(String.java:658)
>       at 
> org.apache.commons.cli.HelpFormatter.findWrapPos(HelpFormatter.java:904)
>       at 
> org.apache.commons.cli.HelpFormatter.renderWrappedText(HelpFormatter.java:812)
>       at 
> org.apache.commons.cli.HelpFormatter.printWrapped(HelpFormatter.java:694)
>       at 
> org.apache.commons.cli.HelpFormatter.printWrapped(HelpFormatter.java:679)
>       at 
> org.apache.commons.cli.HelpFormatter.printHelp(HelpFormatter.java:486)
>       at 
> org.apache.commons.cli.HelpFormatter.printHelp(HelpFormatter.java:443)
>       at org.apache.commons.cli.HelpFormatter$printHelp.call(Unknown Source)
>       at groovy.util.CliBuilder.usage(CliBuilder.groovy:275)
>       at groovy.util.CliBuilder$usage.call(Unknown Source)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
>       at 
> com.pixeon.medical.pacs.tool.config.TestWithFiles.main(TestWithFiles.groovy:26)
> {code}
> Workaround is to overwrite CliBuilder.width to a large number.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to