Skip to content
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

fix checksum bug #2401 #2403

Merged
merged 4 commits into from
Mar 29, 2020
Merged

fix checksum bug #2401 #2403

merged 4 commits into from
Mar 29, 2020

Conversation

lkxiaolou
Copy link
Contributor

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

fix the checksum bug, refer to #2401

MessageDigest is not safe in multi-thread

Brief changelog

Add a lock to ensure execute success

Verifying this change

see InstancesTest

@lkxiaolou lkxiaolou changed the title fix checksum bug fix checksum bug #2401 Mar 3, 2020
if (MESSAGE_DIGEST != null) {
checksum =
new BigInteger(1, MESSAGE_DIGEST.digest((sb.toString()).getBytes(Charset.forName("UTF-8")))).toString(16);
if (MESSAGE_DIGEST_LOCAL.get() != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you can consider holding the MessageDigest with a local variable to avoid getting again later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you can consider holding the MessageDigest with a local variable to avoid getting again later

done

@lkxiaolou
Copy link
Contributor Author

@chuntaojun I have unified the md5 calculation in thread-local way instead of using a lock

@nkorange nkorange merged commit b7a2c75 into alibaba:develop Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants