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

Akira AJISAKA commented on HADOOP-11602:
----------------------------------------

Some comments:
1. We should capitalize the string after it is lower cased.
{code:title=AppController.java}
-        tt = tt.isEmpty() ? "All" : StringUtils.capitalize(MRApps.taskType(tt).
-            toString().toLowerCase(Locale.US));
+        tt = tt.isEmpty() ? "All" :
+            org.apache.hadoop.util.StringUtils.toLowerCase(
+                StringUtils.capitalize(MRApps.taskType(tt).toString()));
{code}

2. Found double toUpperCase/toLowerCase operations in 
* CheckUploadContentTypeFilter.java
* HdfsServerConstants.java
* FSEditLogOp.java
* DistCpUtils.java

3. I'm thinking we can use {{StringUtils.equalsIgnoreCase}} in
{code}
-      String sMU = sMultiple.toUpperCase();
-      if(B.name().toUpperCase().endsWith(sMU))
+      String sMU = StringUtils.toUpperCase(sMultiple);
+      if(StringUtils.toUpperCase(B.name()).endsWith(sMU))
         return B;
-      if(KB.name().toUpperCase().endsWith(sMU))
+      if(StringUtils.toUpperCase(KB.name()).endsWith(sMU))
         return KB;
-      if(MB.name().toUpperCase().endsWith(sMU))
+      if(StringUtils.toUpperCase(MB.name()).endsWith(sMU))
         return MB;
-      if(GB.name().toUpperCase().endsWith(sMU))
+      if(StringUtils.toUpperCase(GB.name()).endsWith(sMU))
         return GB;
-      if(TB.name().toUpperCase().endsWith(sMU))
+      if(StringUtils.toUpperCase(TB.name()).endsWith(sMU))
         return TB;
{code}

4. You can remove unused import from
* ComparableVersion.java
* FileSystemContractBaseTest.java
* AppController.java
* FileSystemCounterGroup.java
* TestSwiftFileSystemExtendedContract.java
* FSDownload.java
* HamletGen.java

Minor nits:
1. These lines are over 80 characters.
{code:title=DelegationTokenAuthenticator.java}
-      contentType = (contentType != null) ? contentType.toLowerCase()
+      contentType = (contentType != null) ? StringUtils.toLowerCase(contentType
                                           : null;
{code}
2. Tab characters are inserted in AzureNativeFileSystemStore.java
3. Would you add a whitespace between , and args\[i\]?
{code:title=HadoopLogsAnalyzer.java}
-      if ("-omit-task-details".equals(args[i].toLowerCase())) {
+      if (StringUtils.equalsIgnoreCase("-omit-task-details",args[i])) {code}

By the way, the below if statement is useless.
{code:title=Environment.java}
-    String lowerOs = OS.toLowerCase();
+    String lowerOs = StringUtils.toLowerCase(OS);
     if (OS.indexOf("Windows") > -1) {
{code}
"Windows" should be "windows". I'll file a jira for this.

> Fix toUpperCase/toLowerCase to use Locale.ENGLISH
> -------------------------------------------------
>
>                 Key: HADOOP-11602
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11602
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 2.6.0
>            Reporter: Tsuyoshi Ozawa
>            Assignee: Tsuyoshi Ozawa
>         Attachments: HADOOP-11602-001.patch, HADOOP-11602-002.patch, 
> HADOOP-11602-003.patch, HADOOP-11602-branch-2.001.patch, 
> HADOOP-11602-branch-2.002.patch
>
>
> String#toLowerCase()/toUpperCase() without a locale argument can occur 
> unexpected behavior based on the locale. It's written in 
> [Javadoc|http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#toLowerCase()]:
> {quote}
> For instance, "TITLE".toLowerCase() in a Turkish locale returns "t\u0131tle", 
> where '\u0131' is the LATIN SMALL LETTER DOTLESS I character
> {quote}
> This issue is derived from HADOOP-10101.



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

Reply via email to