Skip to content

MessageDigest is not thread safe and for the same input, it can generate different hash #816

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

Closed
hamid646m opened this issue Apr 4, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@hamid646m
Copy link
Contributor

hamid646m commented Apr 4, 2022

MessageDigest is not thread safe, therefore if there are multiple requests in quick succession, different hash is returned for the same input.

Consequently, idempotent contract is broken and requests are treated as new for the same IdempotentKey

Expected Behavior

For the same IdempotentKey, same hash must be generated.

When generating Hash value, a new instance of MessageDigest should be used.

I am creating a PR to fix this issue.

this here explain thread safety issue of MessageDigest

@hamid646m hamid646m added the bug Something isn't working label Apr 4, 2022
@hamid646m
Copy link
Contributor Author

we could also used DigestUtils which is thread-safe

@github-actions
Copy link
Contributor

This is now released under 1.12.1 version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants