hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brahma Reddy Battula (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-8705) BlockStoragePolicySuite uses equalsIgnoreCase for name lookup, won't work in all locales
Date Thu, 03 Dec 2015 07:20:11 GMT

    [ https://issues.apache.org/jira/browse/HDFS-8705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15037423#comment-15037423
] 

Brahma Reddy Battula commented on HDFS-8705:
--------------------------------------------

As I mentioned in the earlier {{String.equalIgoreCase()}} is locale free.And thanks [~walter.k.su]
and [~szetszwo] for your inputs.

{{String.equalIgoreCase()}} internally uses, {{Character.toLowerCase()}} and {{Character.toUpperCase()}},
this will not change based on Locale.
but {{String.toLowerCase()}} and {{String.toUpperCase()}} depends in Locale

 *Sample Test Code:* 

{code}
public static void main(String[] args) {
    Locale trlocale = new Locale("tr", "TR");
    Locale.setDefault(trlocale);
    System.out.println(Locale.getDefault()); // tr_TR
    char dottedUpper = '\u0130';
    char dottedLower = '\u0069';
    char dotlessUpper = '\u0049';
    char dotlessLower = '\u0131';

    char[] chars = new char[] { dottedLower, dottedUpper, dotlessLower,
        dotlessUpper };
    for (int i = 0; i < chars.length; i++) {
      char ch = chars[i];
      System.out.println("" + ch);
      System.out.println(" Character.toUpperCase('" + ch + "') --> "
          + Character.toUpperCase(ch));
      System.out.println(" Character.toLowerCase('" + ch + "') --> "
          + Character.toLowerCase(ch));
      String chString = new String(new char[] { ch });
      System.out.println(" \"" + chString + "\".toUpperCase() --> "
          + chString.toUpperCase());
      System.out.println(" \"" + chString + "\".toLowerCase() --> "
          + chString.toLowerCase());
    }
  }
{code}
{{Character.toLowerCase()}} and {{Character.toUpperCase()}} always maps to English characters,
not turkish characters.


 *Output when char is "I"* 
{code}
 Character.toUpperCase('I') --> I
 Character.toLowerCase('I') --> i
 "I".toUpperCase() --> I
 "I".toLowerCase() --> ı
{code}

> BlockStoragePolicySuite uses equalsIgnoreCase for name lookup, won't work in all locales
> ----------------------------------------------------------------------------------------
>
>                 Key: HDFS-8705
>                 URL: https://issues.apache.org/jira/browse/HDFS-8705
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namenode
>    Affects Versions: 2.8.0
>            Reporter: Steve Loughran
>            Assignee: Brahma Reddy Battula
>            Priority: Minor
>         Attachments: HDFS-8705-002.patch, HDFS-8705.patch
>
>
> Looking at {{BlockStoragePolicySuite.getPolicy(name)}}, is using {{equalsIgnoreCase()}}
to find a policy which matches a name.
> This will not work in all locales. It must use {{toLowerCase(Locale.ENGLISH).equals(name)}}



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

Mime
View raw message