hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tsz Wo Nicholas Sze (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 02:41:11 GMT

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

Tsz Wo Nicholas Sze commented on HDFS-8705:
-------------------------------------------

I agree that equalsIgnoreCase is safe for all English letters and all locales; try the test
program below.
{code}
  public static void main(String[] args) {
    final String allLetters = getAllLetters();
    System.out.println(allLetters);
    for(Locale locale : Locale.getAvailableLocales()) {
      System.out.println("locale = " + locale);

      final String upper = allLetters.toUpperCase(locale);
      final String lower = allLetters.toLowerCase(locale);
      System.out.println("  upper = " + upper);
      System.out.println("  lower = " + lower);
      assertEqualsIgnoreCase(upper, lower);
      assertEqualsIgnoreCase(upper, allLetters);
      assertEqualsIgnoreCase(lower, allLetters);
    }
  }
  static String getAllLetters() {
    final StringBuilder b = new StringBuilder();
    for(char lower = 'a', upper = 'A'; lower <= 'z'; lower++, upper++) {
      b.append(lower).append(upper);
    }
    return b.toString();
  }
  static void assertEqualsIgnoreCase(String a, String b) {
    if (!a.equalsIgnoreCase(b)) {
      throw new AssertionError("a.equalsIgnoreCase(b) = " + a.equalsIgnoreCase(b)
          + "\na = " + a + "\nb=" + b);
    }
  }
{code}
In particular, below is the output for Turkish.
{code}
locale = tr_TR
  upper = AABBCCDDEEFFGGHHİIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ
  lower = aabbccddeeffgghhiıjjkkllmmnnooppqqrrssttuuvvwwxxyyzz
{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