[jira] [Created] (LANG-748) Change StringUtils.chomp(String, String) to be the same as StringUtils.removeEnd

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (LANG-748) Change StringUtils.chomp(String, String) to be the same as StringUtils.removeEnd

ASF GitHub Bot (Jira)
Change StringUtils.chomp(String, String) to be the same as StringUtils.removeEnd
--------------------------------------------------------------------------------

                 Key: LANG-748
                 URL: https://issues.apache.org/jira/browse/LANG-748
             Project: Commons Lang
          Issue Type: Improvement
            Reporter: Henri Yandell


Verneri Åberg reported on the list:

I was just browsing through StringUtils Api (versions 2.5, 2.6 and
3.0.1) and found two very similar looking methods

chomp(String,String)
and
removeEnd(String, String)

So I started to wonder what is the difference here and looked at the
source code.

To my astonishment the only difference is that chomp returns the source
string immediately if the removed string is null and remove end
additionally checks for empty strings too.

So wouldn't it be better to substitute the duplication by simply
replacing the chomp method with following version?

public String chomp(String source, String separator) {
       return removeEnd(source,separator);
}

Or is there some hidden idea for two different implementations of the
same string chompping function? if there is maybe it should be added to
both methods javadocs?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] [Closed] (LANG-748) Change StringUtils.chomp(String, String) to be the same as StringUtils.removeEnd

ASF GitHub Bot (Jira)

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

Henri Yandell closed LANG-748.
------------------------------

       Resolution: Fixed
    Fix Version/s: 3.0.2

svn ci -m "Deprecating chomp(String, String) per Verneri Åberg's report in LANG-748"
Sending        src/main/java/org/apache/commons/lang3/StringUtils.java
Transmitting file data .
Committed revision 1161997.


> Change StringUtils.chomp(String, String) to be the same as StringUtils.removeEnd
> --------------------------------------------------------------------------------
>
>                 Key: LANG-748
>                 URL: https://issues.apache.org/jira/browse/LANG-748
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Henri Yandell
>             Fix For: 3.0.2
>
>
> Verneri Åberg reported on the list:
> I was just browsing through StringUtils Api (versions 2.5, 2.6 and
> 3.0.1) and found two very similar looking methods
> chomp(String,String)
> and
> removeEnd(String, String)
> So I started to wonder what is the difference here and looked at the
> source code.
> To my astonishment the only difference is that chomp returns the source
> string immediately if the removed string is null and remove end
> additionally checks for empty strings too.
> So wouldn't it be better to substitute the duplication by simply
> replacing the chomp method with following version?
> public String chomp(String source, String separator) {
>        return removeEnd(source,separator);
> }
> Or is there some hidden idea for two different implementations of the
> same string chompping function? if there is maybe it should be added to
> both methods javadocs?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira