1126 |
|
} |
1127 |
|
|
1128 |
|
/** |
1129 |
< |
* A CyclicBarrier that fails with AssertionFailedErrors instead |
1130 |
< |
* of throwing checked exceptions. |
1129 |
> |
* A CyclicBarrier that uses timed await and fails with |
1130 |
> |
* AssertionFailedErrors instead of throwing checked exceptions. |
1131 |
|
*/ |
1132 |
|
public class CheckedBarrier extends CyclicBarrier { |
1133 |
|
public CheckedBarrier(int parties) { super(parties); } |
1134 |
|
|
1135 |
|
public int await() { |
1136 |
|
try { |
1137 |
< |
return super.await(); |
1137 |
> |
return super.await(2 * LONG_DELAY_MS, MILLISECONDS); |
1138 |
> |
} catch (TimeoutException e) { |
1139 |
> |
throw new AssertionFailedError("timed out"); |
1140 |
|
} catch (Exception e) { |
1141 |
|
AssertionFailedError afe = |
1142 |
|
new AssertionFailedError("Unexpected exception: " + e); |