storm
storm copied to clipboard
[STORM-3753] Change String.getBytes() to DFSUtil.string2Bytes(String)…
… 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.
Hi @Ethanlm , thanks for your recommendation, I have changed the code correspondingly, which use data.getBytes(xxx). Please review.
Currently, I do not have a test case for this, but a very similar one can be found here: https://github.com/apache/hadoop/commit/ab3885f2c8cfd63ff94e548c40db3b4ea52c12e8 .
I believe that providing the encoding is a good way to make the code more robust.
Please kindly check. Thanks.
There are other locations where the default encoding of the OS is used to create String instances. Would you like to take a look and rebase @dbgp2021 ?
Eventhubs was removed with https://issues.apache.org/jira/projects/STORM/issues/STORM-3988?filter=allissues