commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (Commented) (JIRA)" <>
Subject [jira] [Commented] (LANG-784) Strange behavior on StringUtils.difference
Date Thu, 12 Jan 2012 08:13:38 GMT


Henri Yandell commented on LANG-784:

I agreed with Arnaud that this is odd. Primarily because of the following:

    System.err.println(StringUtils.difference("abc", "ab"));

This results in an empty String. That's just useless :) The answer is "c" and not empty String.
Easy to fix by swapping the parameters based on length so that the longer parameter is always

API-wise, I wouldn't want to change if it was only the example that Arnaud lists, but if any
related content returns a non-intuitive reply it seems to me that the method is buggy and
should be fixed.
> Strange behavior on StringUtils.difference
> ------------------------------------------
>                 Key: LANG-784
>                 URL:
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.0.1
>            Reporter: Arnaud BRUNET
>            Priority: Minor
> Hi,
> The behavior of the method StringUtils.difference () behaves in a non-intuitive (explain
in the javadoc).
> StringUtils.difference ("abc", "") returns "" as intuitively expected to be "abc".
> Is it possible to change this behavior ?
> Regards,
> Arnaud

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message