commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholas DeFazio (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1161) StringUtils.startsWith returns true for an empty string comparison
Date Thu, 06 Aug 2015 19:21:04 GMT

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

Nicholas DeFazio updated LANG-1161:
-----------------------------------
    Description: 
When working on a project I noticed that...

{code}
        boolean match = StringUtils.startsWith("abcdef", "");
        System.out.println(match); //prints true
{code}

I'm not sure if this is intended, but my thought was that a comparison of a non empty string
to an empty string should result in a false, similar to how null is handled.

{code}
        boolean match = StringUtils.startsWith("abcdef", null);
        System.out.println(match); //prints false
{code}

  was:
When working on a project I noticed that...

{code}
        boolean match = StringUtils.startsWith("abcdef", "");
        System.out.println(match); //prints true
{code}

My thought was that a comparison of a non empty string to an empty string should result in
a false, similar to how null is handled.

{code}
        boolean match = StringUtils.startsWith("abcdef", null);
        System.out.println(match); //prints false
{code}


> StringUtils.startsWith returns true for an empty string comparison
> ------------------------------------------------------------------
>
>                 Key: LANG-1161
>                 URL: https://issues.apache.org/jira/browse/LANG-1161
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 3.3
>            Reporter: Nicholas DeFazio
>            Priority: Trivial
>
> When working on a project I noticed that...
> {code}
>         boolean match = StringUtils.startsWith("abcdef", "");
>         System.out.println(match); //prints true
> {code}
> I'm not sure if this is intended, but my thought was that a comparison of a non empty
string to an empty string should result in a false, similar to how null is handled.
> {code}
>         boolean match = StringUtils.startsWith("abcdef", null);
>         System.out.println(match); //prints false
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message