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

ASF GitHub Bot commented on HDFS-11115:
---------------------------------------

github-actions[bot] commented on PR #152:
URL: https://github.com/apache/hadoop/pull/152#issuecomment-3706525845

   We're closing this stale PR because it has been open for 100 days with no 
activity. This isn't a judgement on the merit of the PR in any way. It's just a 
way of keeping the PR queue manageable.
   If you feel like this was a mistake, or you would like to continue working 
on it, please feel free to re-open it and ask for a committer to remove the 
stale tag and review again.
   Thanks all for your contribution.




> Remove bytes2Array and string2Bytes
> -----------------------------------
>
>                 Key: HDFS-11115
>                 URL: https://issues.apache.org/jira/browse/HDFS-11115
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: hdfs, hdfs-client
>            Reporter: Sahil Kang
>            Priority: Minor
>
> In DFSUtilClient.java we have something like:
> {code: language=java}
> public static byte[] string2Bytes(String str) {
>   try {
>     return str.getBytes("UTF-8");
>   } catch (UnsupportedEncodingException e) {
>     throw new IllegalArgumentException("UTF8 decoding is not supported", e);
>   }
> }
> static String bytes2String(byte[] bytes, int offset, int length) {
>   try {
>     return new String(bytes, offset, length, "UTF-8");
>   } catch (UnsupportedEncodingException e) {
>     throw new IllegalArgumentException("UTF8 encoding is not supported", e);
>   }
> }
> {code}
> Using StandardCharsets, these methods become trivial:
> {code: language=java}
> public static byte[] string2Bytes(String str) {
>   return str.getBytes(StandardCharsets.UTF_8);
> }
> static String bytes2String(byte[] bytes, int offset, int length) {
>   return new String(bytes, offset, length, StandardCharsets.UTF_8);
> }
> {code}
> I think we should remove these methods and use StandardCharsets whenever we 
> need to convert between bytes and strings.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to