Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 58152D168 for ; Sun, 28 Oct 2012 22:33:13 +0000 (UTC) Received: (qmail 31294 invoked by uid 500); 28 Oct 2012 22:33:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 31179 invoked by uid 500); 28 Oct 2012 22:33:12 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 31027 invoked by uid 99); 28 Oct 2012 22:33:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Oct 2012 22:33:12 +0000 Date: Sun, 28 Oct 2012 22:33:12 +0000 (UTC) From: "Efthymis Sarbanis (JIRA)" To: issues@commons.apache.org Message-ID: <809462359.37122.1351463592847.JavaMail.jiratomcat@arcas> In-Reply-To: <1998135727.75167.1347549547421.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (LANG-823) StringUtils.split should handle empty strings the same as other content MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-823?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Efthymis Sarbanis updated LANG-823: ----------------------------------- Attachment: LANG-823.test.patch > StringUtils.split should handle empty strings the same as other content > ----------------------------------------------------------------------- > > Key: LANG-823 > URL: https://issues.apache.org/jira/browse/LANG-823 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* > Affects Versions: 2.5 > Reporter: Mark Farnsworth > Priority: Minor > Attachments: LANG-823.patch, LANG-823.test.patch > > > When a user issues a split with a delimiter and the string does not contain the delimiter the result is normally an array with one item that contains the content of the string. > It seems strange that StringUtils does not behave consistently in the context of an empty string. > For example, > {code} > package maf.test; > import junit.framework.TestCase; > import org.apache.commons.lang.StringUtils; > public class StringUtilsTest extends TestCase { > public void testStringUtils() { > // The following two lines work correctly > assertTrue(StringUtils.split("x",",")[0].equals("x")); > assertTrue(StringUtils.split(" ",",")[0].equals(" ")); > > // The following should also work but > // in commons-lang-2.5.jar the test fails here > assertTrue(StringUtils.split("",",")[0].equals("")); > } > } > {code} > There seems to be no logic behind making split work differently in the case of empty strings. > For the next release, I would suggest a behavior change for StringUtils this will have side effects but would be more logically consistent. > Users who depend on the old behavior could stick with 2.5 release and/or implement code in the caller to simulate the behavior. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira