-
Notifications
You must be signed in to change notification settings - Fork 12k
Replace Charset.forName("UTF-8") with StandardCharsets.UTF_8 #4024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can an ISSUE be created for this PR? |
#4068 I have created an issue for this PR. |
Codecov Report
@@ Coverage Diff @@
## develop #4024 +/- ##
=============================================
- Coverage 47.90% 47.90% -0.01%
- Complexity 5001 5002 +1
=============================================
Files 633 633
Lines 42523 42523
Branches 5573 5573
=============================================
- Hits 20371 20369 -2
- Misses 19654 19660 +6
+ Partials 2498 2494 -4
Continue to review full report at Codecov.
|
System.out.printf("Producer startup OK%n"); | ||
|
||
{ | ||
Message message = producer.createBytesMessage("OMS_HELLO_TOPIC", "OMS_HELLO_BODY".getBytes(Charset.forName("UTF-8"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use StandardCharsets.UTF_8 ? IMO, some os may use gbk as default decoder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary to specify the encode charset for message body.
As long as one encode and decode the message with the same charset, he shall get the correct message.
…rsets.UTF_8 (apache#4024) * Replace Charset.forName("UTF-8") with StandardCharsets.UTF_8 * Remove the specification of Charset according to SimplePullConsumer
What is the purpose of the change
Constant charset defined by String (for example, "UTF-8") can be replaced with the predefined StandardCharsets.UTF_8 code.
The code after the fix may work faster, because the charset lookup becomes unnecessary.
Brief changelog
Replace Charset.forName("UTF-8") with StandardCharsets.UTF_8