This repository has been archived by the owner on Jul 25, 2020. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This will be very small if delayMs happens to be small. Is that intentional?
Also, can we use a shared Random here - they should be threadsafe. That's not as random as using a new one every time, but for this application that should be fine?
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.
delayMs
defaults to a small value, 50 ms, although scales up to 500 ms. 10% jitter may be suboptimal; I chose this value to agree with our existing tests.Java 6 Javadoc does not guarantee thread-safety:
http://docs.oracle.com/javase/6/docs/api/java/util/Random.html
Although StackOverflow and the Java bug tracker suggest that it is:
http://stackoverflow.com/questions/5819638/is-random-class-thread-safe
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6362070
Prefer to keep this simple if possible since we only see this on the uncommon failure path.
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.
Ah, OK. Then let's keep as-is. Just wondering if we want to change the jitter to min(5ms, delay * 0.1) or so?