[ https://issues.apache.org/jira/browse/LANG-1478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16915505#comment-16915505 ]
Peter Verhas commented on LANG-1478: ------------------------------------ It is not only that case. It is in every case where `a.b.c.ddd. ...` would be OK and just exactly the required length (`a`, `b`, `c` are abbreviated in this sample, but `ddd` is not). The current algorithm will abbreviate it to `a.b.c.d. ...` abbreviating `ddd` unnecessarily. I agree with you that a change like that may not be introduced in a minor release, but it does not seem to a strict policy. My project was broken upgrading from 3.4 to 3.9 as `isAnyEmpty(null)` changed from true to false. If the decision is that we have to wait for a major release then I suggest NOT TO IMPLEMENT this change, but rather the one I suggested in LANG-1480. What is your opinion about that? > ClassUtils getAbbreviatedName uses len one character shorter > ------------------------------------------------------------ > > Key: LANG-1478 > URL: https://issues.apache.org/jira/browse/LANG-1478 > Project: Commons Lang > Issue Type: Bug > Affects Versions: 3.9 > Reporter: Peter Verhas > Assignee: Bruno P. Kinoshita > Priority: Minor > Time Spent: 50m > Remaining Estimate: 0h > > The {{ClassUtils}} method {{getAbbreviatedName}} calculates the required > lenght one character short. That way > {code} > final String ANY_CLASS_FULL_NAME = "...."; > assertEquals("ANY_CLASS_FULL_NAME ", > ClassUtils.getAbbreviatedName(ANY_CLASS_FULL_NAME , ANY_CLASS_FULL_NAME > .length())); > {code} > will abbreviate the class name, although we are asking exactly the same > number of characters as they are there. The solution is that > {code} > if (availableSpace > 0) { > {code} > has to be modified to > {code} > if (availableSpace >= 0) { > {code} > since the value zero means that we exactly used up the available character > width. > This is just a quick fix for this issue, but generally, the algorithm is > faulty. It runs many times out of the desired length. It actually uses the > len parameter, not as the desired final length but rather a length for which > what is out of the range on the left that has to be abbreviated. For that, > the code could be much simpler. (See LANG-1480.) -- This message was sent by Atlassian Jira (v8.3.2#803003)