equal
deleted
inserted
replaced
729 } |
729 } |
730 |
730 |
731 /** |
731 /** |
732 * Returns a random element from given choices. |
732 * Returns a random element from given choices. |
733 */ |
733 */ |
|
734 <T> T chooseRandomly(List<T> choices) { |
|
735 return choices.get(ThreadLocalRandom.current().nextInt(choices.size())); |
|
736 } |
|
737 |
|
738 /** |
|
739 * Returns a random element from given choices. |
|
740 */ |
734 <T> T chooseRandomly(T... choices) { |
741 <T> T chooseRandomly(T... choices) { |
735 return choices[ThreadLocalRandom.current().nextInt(choices.length)]; |
742 return choices[ThreadLocalRandom.current().nextInt(choices.length)]; |
736 } |
743 } |
737 |
744 |
738 /** |
745 /** |
1797 public static class CheckedBarrier extends CyclicBarrier { |
1804 public static class CheckedBarrier extends CyclicBarrier { |
1798 public CheckedBarrier(int parties) { super(parties); } |
1805 public CheckedBarrier(int parties) { super(parties); } |
1799 |
1806 |
1800 public int await() { |
1807 public int await() { |
1801 try { |
1808 try { |
1802 return super.await(2 * LONG_DELAY_MS, MILLISECONDS); |
1809 return super.await(LONGER_DELAY_MS, MILLISECONDS); |
1803 } catch (TimeoutException timedOut) { |
1810 } catch (TimeoutException timedOut) { |
1804 throw new AssertionError("timed out"); |
1811 throw new AssertionError("timed out"); |
1805 } catch (Exception fail) { |
1812 } catch (Exception fail) { |
1806 throw new AssertionError("Unexpected exception: " + fail, fail); |
1813 throw new AssertionError("Unexpected exception: " + fail, fail); |
1807 } |
1814 } |