[jira] [Work logged] (LANG-1480) ClassUtils. getAbbreviatedName(String ,int) returns too long result

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Work logged] (LANG-1480) ClassUtils. getAbbreviatedName(String ,int) returns too long result

ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/LANG-1480?focusedWorklogId=300782&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-300782 ]

ASF GitHub Bot logged work on LANG-1480:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Aug/19 23:48
            Start Date: 24/Aug/19 23:48
    Worklog Time Spent: 10m
      Work Description: kinow commented on pull request #446: LANG-1480 getAbbreviatedName refactored to create appropriate length …
URL: https://github.com/apache/commons-lang/pull/446#discussion_r317377606
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/ClassUtils.java
 ##########
 @@ -433,11 +432,13 @@ public static String getAbbreviatedName(final Class<?> cls, final int len) {
      * <tr><td>"java.lang.String"</td><td> 5</td><td>"j.l.String"</td></tr>
      * <tr><td>"java.lang.String"</td><td>15</td><td>"j.lang.String"</td></tr>
      * <tr><td>"java.lang.String"</td><td>30</td><td>"java.lang.String"</td></tr>
+     * <tr><td>"org.apache.commons.lang3.ClassUtils"</td><td>18</td><td>"o.a.c.l.ClassUtils"</td></tr>
      * </table>
      * @param className  the className to get the abbreviated name for, may be {@code null}
      * @param len  the desired length of the abbreviated name
-     * @return the abbreviated name or an empty string
-     * @throws IllegalArgumentException if len &lt;= 0
+     * @return the abbreviated name or an empty string if the specified
+     * class name is {@code null} or empty string
+     * @throws IllegalArgumentException if {@code len <= 0}
 
 Review comment:
   Thanks for updating the docs!
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 300782)
    Remaining Estimate: 23h 20m  (was: 23.5h)
            Time Spent: 40m  (was: 0.5h)

> ClassUtils. getAbbreviatedName(String ,int) returns too long result
> -------------------------------------------------------------------
>
>                 Key: LANG-1480
>                 URL: https://issues.apache.org/jira/browse/LANG-1480
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.9
>         Environment: Environment independent.
>            Reporter: Peter Verhas
>            Priority: Major
>   Original Estimate: 24h
>          Time Spent: 40m
>  Remaining Estimate: 23h 20m
>
> In some cases, the algorithm decides incorrectly when to which package names to abbreviate. For example, abbreviating
> {{org.apache.commons.lang3.ClassUtils}} to the length 18 will result {{o.a.c.lang3.ClassUtils}} (22 characters) instead of {{o.a.c.l.ClassUtils}} (18 characters as requested). The reason for this is that the algorithm starts from the right and goes to the left abbreviating the packages and starts to abbreviate the packages when it runs out of the available space.
> Instead, the algorithm should start from the left and abbreviate all packages that would result in a too-long string without abbreviating the package name.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)