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

Aaron T. Myers commented on HDFS-4032:
--------------------------------------

Patch looks pretty good to me. Almost all the changes look like they shouldn't 
change any behavior at all, but I think this one will:
{code}
   public static byte[] string2Bytes(String str) {
-    try {
-      return str.getBytes("UTF8");
-    } catch(UnsupportedEncodingException e) {
-      assert false : "UTF8 encoding is not supported ";
-    }
-    return null;
+    return str.getBytes(Charsets.UTF_8);
   }
{code}

Since assertions are typically disabled when not running the tests, this will 
result in a behavior change when running in production. Before this change, the 
assert in the catch block would just be skipped and null would be returned. 
After this change, the UnsupportedEncodingException would be thrown from this 
method. It's not obvious to me whether this could be problematic or not. 
Thoughts?
                
> Specify the charset explicitly rather than rely on the default
> --------------------------------------------------------------
>
>                 Key: HDFS-4032
>                 URL: https://issues.apache.org/jira/browse/HDFS-4032
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>    Affects Versions: 2.0.0-alpha
>            Reporter: Eli Collins
>            Assignee: Eli Collins
>         Attachments: hdfs-4032.txt
>
>
> Findbugs 2 warns about relying on the default Java charset instead of 
> specifying it explicitly. Given that we're porting Hadoop to different 
> platforms it's better to be explicit.

--
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

Reply via email to