GetCodeOwnersForPathInChange: Use a hash of the change number as a seed

If code owners have the same score they should be returned in a random
order, however for one change the same random order should be
consistently applied across requests. This is achieved by using the
change number as a seed for the randomisation. However it turned out
that with java.util.Random nearby seeds are prone to produce the same
random numbers. This is bad for change series, where the change IDs only
differ by 1, so all seeds are nearby and hence always the same code
owners will be suggested for all changes in the series. To avoid this we
are now using a hash of the change ID as a seed for the randomisation
(instead of the change ID itself). This way the seeds that are used for
a change series are ensured to be distant and hence the randomisation
should work better now.

While we are fixing this also add a test that ensures that using
different seeds produces a different order at least once. FWIW this test
was also succeeding with the old code.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Idd038765f5e512280b4804d23e32a63b15b73573
2 files changed
tree: 2a7b8c507035de43a6dca40c59e1dc60daf50e8d
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. test/
  6. ui/
  7. .eslintrc.json
  8. .gitignore
  9. .gitreview
  10. bower.json
  11. BUILD
  12. LICENSE
  13. package-lock.json
  14. package.json
  15. README.md
README.md

Gerrit Code Review code-owners plugin

This plugin provides support for defining code owners for files in a repository.

If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.

Also see resources/Documentation/about.md.

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md.