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 0041A18CB0 for ; Fri, 12 Jun 2015 14:08:01 +0000 (UTC) Received: (qmail 63832 invoked by uid 500); 12 Jun 2015 14:08:00 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 63732 invoked by uid 500); 12 Jun 2015 14:08:00 -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 63718 invoked by uid 99); 12 Jun 2015 14:08:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Jun 2015 14:08:00 +0000 Date: Fri, 12 Jun 2015 14:08:00 +0000 (UTC) From: "Aleksandr Bogush (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (LANG-1148) StringUtils.isBlank does not work correctly with strings containing non-breakable whitespace characters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Aleksandr Bogush created LANG-1148: -------------------------------------- Summary: StringUtils.isBlank does not work correctly with strings containing non-breakable whitespace characters Key: LANG-1148 URL: https://issues.apache.org/jira/browse/LANG-1148 Project: Commons Lang Issue Type: Bug Components: lang.* Affects Versions: 2.6 Environment: Windows 8.1 x64 , Java 1.8, but can be reproduced in any environment with an official Oracle JDK or JRE Reporter: Aleksandr Bogush Priority: Minor isBlank uses java.lang.Character.isWhitespace(char ch) method, which has not been changed for a long time for backward compatibility. Over the years non-breakable whitespaces were introduced and are now used in some cases. So if we execute the code org.apache.commons.lang.StringUtils.isBlank("\u00A0"); //returns false org.apache.commons.lang.StringUtils.isBlank("\u202F"); //returns false org.apache.commons.lang.StringUtils.isBlank("\u2007"); //returns false we will get 3 falses, which is not right, according to StringUtils.isBlank documentation: Checks if a String is whitespace, empty ("") or null. I suggest fixing it by using regex pattern "^[\\p{Z}]*$" instead of looping over the string characters. I know that it is a bit less fast than it works now, but it will work much more correctly. I would be glad to do it myself and write unit tests for it, so if you want, please contact me via email alex.bohush@gmail.com Additionally, I would modify the documentation itself too, because it does not tell that it returns true when meeting multiple whitespaces. -- This message was sent by Atlassian JIRA (v6.3.4#6332)