commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frederik Naujoks (JIRA)" <>
Subject [jira] [Commented] (LANG-673) WordUtils.abbreviate() throws undocumented StringIndexOutOfBoundsException (ACTION: Method Removed)
Date Fri, 12 Aug 2011 12:21:27 GMT


Frederik Naujoks commented on LANG-673:

Hi, the WordUtils.abbreviate method operated on words, whereas the StringUtils.abbreviate
method ignores "words".

>From the commons.lang 2.4 javadoc (,%20int,%20int,%20java.lang.String%29)
Abbreviates a string nicely. This method searches for the first space after the lower limit
and abbreviates the String there. It will also append any String passed as a parameter to
the end of the String. The upper limit can be specified to forcibly abbreviate a String. 

StringUtils.abbreviate will cut the supplied String at the given limits. In my usecase that
behavior is not desirable, I do need the WordUtils.abbreviate functionality.

Both abbreviate methods are useful, depending on the usecase.
Please re-add the WordUtils.abbreviate method or supply a method with the old behavior elsewhere.


> WordUtils.abbreviate() throws undocumented StringIndexOutOfBoundsException (ACTION: Method
> ---------------------------------------------------------------------------------------------------
>                 Key: LANG-673
>                 URL:
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.5
>            Reporter: Paul Benedict
>             Fix For: 3.0
> The javadoc does not indicate that the string must already be long enough to abbreviate;
yet it really does or an Exception is thrown. For example, if you try to abbreviate a string
of length 10 at 40 characters, this will fail. I believe this should be allowed... just without
any abbreviation.

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message