lizhanhui commented on PR #5172: URL: https://github.com/apache/rocketmq/pull/5172#issuecomment-1257095641
@alexcao2018 > Because previous version using the method of String getBytes(String) that throws UnsupportedEncodingException, I change to use getBytes(Charset) , overload, making code nice No, you are not making the code nice, you are creating chances of introducing Silent Data Corruption. See the [Java doc here](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#getBytes(java.nio.charset.Charset)) **This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement byte array.** This is not expected, should use CharsetEncoder to enhance the solution, as is elaborated in the Javadoc. In terms of method signature on exception, > "It would make sense to catch all exceptions raised and translate them into human-friendly messages via standard error output." still holds. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
