[ 
https://issues.apache.org/jira/browse/LANG-1691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17604922#comment-17604922
 ] 

Gary D. Gregory commented on LANG-1691:
---------------------------------------

Hi [~thiyagu_7] 

Thank you for your report.

Please feel free to provide a PR on GitHub (with a test).

> ClassUtils.getShortCanonicalName doesn't use the canonicalName
> --------------------------------------------------------------
>
>                 Key: LANG-1691
>                 URL: https://issues.apache.org/jira/browse/LANG-1691
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.12.0
>            Reporter: Thiyagarajan
>            Priority: Major
>
> The 
> [getShortCanonicalName|https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/ClassUtils.html#getShortCanonicalName-java.lang.Class-]
>  should return the canonical name minus the package name from a Class.
> Also, the javadoc of an overloaded _getShortCanonicalName_ states,
> _If the class is an inner class then the result value will not contain the 
> outer classes. This way the behavior of this method is different from 
> getShortClassName(String). The argument in that case is class name and not 
> canonical name and the return value retains the outer classes._
> But for inner class, its behaviour is similar to _getShortClassName._
> {code:java}
> Class<?> clazz = Map.Entry.class;
> System.out.println(ClassUtils.getShortCanonicalName(clazz)); {code}
> *Actual:* Map.Entry
> *Expected:* Entry
> Looking into the implementation, it calls 
> *getShortCanonicalName(cls.getName()).* I believe it should have been 
> *getShortCanonicalName(cls.getCanonicalName())*
> {code:java}
> public static String getShortCanonicalName(final Class<?> cls) {
>     if (cls == null) {
>         return StringUtils.EMPTY;
>     }
>     return getShortCanonicalName(cls.getName()); //<---
> }
> public static String getShortCanonicalName(final String canonicalName) {
>     return getShortClassName(getCanonicalName(canonicalName));
> } {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to