-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Replace byte array zeroing loop with Arrays.fill and specify charset in String construction #9458
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
base: develop
Are you sure you want to change the base?
Conversation
…2.原代码使用 new String(bos.toByteArray()) 会使用平台默认的字符集进行解码,可能导致跨平台或环境不一致时出现乱码
for (int i = 0; i < bytes.length; i++) { | ||
bytes[i] = (byte) 0x00; | ||
} | ||
Arrays.fill(bytes, (byte) 0x00); // 替换为 Arrays.fill() |
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.
Chinese comments are not allowed
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've made the suggested changes. Please take another look when you have time:)
It would be better to create an issue first and link it to the PR. Additionally, it is recommended to write the title in English and follow the specified format. |
Thanks for your guidance! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #9458 +/- ##
=============================================
- Coverage 48.11% 48.00% -0.11%
+ Complexity 12015 11989 -26
=============================================
Files 1308 1308
Lines 92253 92252 -1
Branches 11808 11807 -1
=============================================
- Hits 44385 44288 -97
- Misses 42373 42454 +81
- Partials 5495 5510 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes
Fixes #9460
Brief Description
This PR improves code readability and portability by replacing manual byte array zeroing and by explicitly specifying a charset when converting bytes to string.
How Did You Test This Change?
These changes are refactorings that do not alter functionality. Existing unit tests continue to pass. Manual testing was also performed to ensure behavior remains consistent.