You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/03/27 09:29:00 UTC

[jira] [Work logged] (HADOOP-17605) Change String.getBytes() to DFSUtil.string2Bytes(String) to avoid Unsupported Encoding Exception

     [ https://issues.apache.org/jira/browse/HADOOP-17605?focusedWorklogId=572999&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-572999 ]

ASF GitHub Bot logged work on HADOOP-17605:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Mar/21 09:28
            Start Date: 27/Mar/21 09:28
    Worklog Time Spent: 10m 
      Work Description: dbgp2021 opened a new pull request #2822:
URL: https://github.com/apache/hadoop/pull/2822


   …) to avoid Unsupported Encoding Exception
   
   Hello,
   I found that DFSUtil.string2Bytes(String) can be used here instead of String.getBytes(). Otherwise, the API String.getBytes() may cause potential risk of UnsupportedEncodingException since the behavior of this method when the string cannot be encoded in the default charset is unspecified. One recommended API is DFSUtil.string2Bytes(String) which provides more control over the encoding process and can avoid this exception. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 572999)
    Remaining Estimate: 0h
            Time Spent: 10m

> Change String.getBytes() to DFSUtil.string2Bytes(String) to avoid Unsupported Encoding Exception
> ------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-17605
>                 URL: https://issues.apache.org/jira/browse/HADOOP-17605
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: dbgp2021
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hello,
> I found that DFSUtil.string2Bytes(String) can be used here instead of String.getBytes(). Otherwise, the API String.getBytes() may cause potential risk of UnsupportedEncodingException since the behavior of this method when the string cannot be encoded in the default charset is unspecified. One recommended API is DFSUtil.string2Bytes(String) which provides more control over the encoding process and can avoid this exception. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org