commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1028) CLONE - StringUtils.countMatches loops forever if substring empty
Date Sun, 20 Jul 2014 10:44:38 GMT

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

Benedikt Ritter updated LANG-1028:
----------------------------------

    Description: 
If you do say StringUtils.countMatches("x", ""), then it goes into an infinite loop.

Also sub isn't checked for null if str is null also. For instance
StringUtils.countMatches(null, null) should throw an NPE instead of 0.

To fix both problems put the following code at the start of the method:

{code:java}
        if (sub.equals("")) {
            return 0;
        }
{code}

  was:
If you do say StringUtils.countMatches("x", ""), then it goes into an infinite loop.

Also sub isn't checked for null if str is null also. For instance
StringUtils.countMatches(null, null) should throw an NPE instead of 0.

To fix both problems put the following code at the start of the method:

        if (sub.equals("")) {
            return 0;
        }


> CLONE - StringUtils.countMatches loops forever if substring empty
> -----------------------------------------------------------------
>
>                 Key: LANG-1028
>                 URL: https://issues.apache.org/jira/browse/LANG-1028
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>         Environment: Operating System: Linux
> Platform: PC
>            Reporter: stagiaire inria lille dascq
>
> If you do say StringUtils.countMatches("x", ""), then it goes into an infinite loop.
> Also sub isn't checked for null if str is null also. For instance
> StringUtils.countMatches(null, null) should throw an NPE instead of 0.
> To fix both problems put the following code at the start of the method:
> {code:java}
>         if (sub.equals("")) {
>             return 0;
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message