1571 |
|
} |
1572 |
|
|
1573 |
|
public void await(CountDownLatch latch, long timeoutMillis) { |
1574 |
+ |
boolean timedOut = false; |
1575 |
|
try { |
1576 |
< |
if (!latch.await(timeoutMillis, MILLISECONDS)) |
1576 |
< |
fail("timed out waiting for CountDownLatch for " |
1577 |
< |
+ (timeoutMillis/1000) + " sec"); |
1576 |
> |
timedOut = !latch.await(timeoutMillis, MILLISECONDS); |
1577 |
|
} catch (Throwable fail) { |
1578 |
|
threadUnexpectedException(fail); |
1579 |
|
} |
1580 |
+ |
if (timedOut) |
1581 |
+ |
fail("timed out waiting for CountDownLatch for " |
1582 |
+ |
+ (timeoutMillis/1000) + " sec"); |
1583 |
|
} |
1584 |
|
|
1585 |
|
public void await(CountDownLatch latch) { |
1587 |
|
} |
1588 |
|
|
1589 |
|
public void await(Semaphore semaphore) { |
1590 |
+ |
boolean timedOut = false; |
1591 |
|
try { |
1592 |
< |
if (!semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS)) |
1590 |
< |
fail("timed out waiting for Semaphore for " |
1591 |
< |
+ (LONG_DELAY_MS/1000) + " sec"); |
1592 |
> |
timedOut = !semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS); |
1593 |
|
} catch (Throwable fail) { |
1594 |
|
threadUnexpectedException(fail); |
1595 |
|
} |
1596 |
+ |
if (timedOut) |
1597 |
+ |
fail("timed out waiting for Semaphore for " |
1598 |
+ |
+ (LONG_DELAY_MS/1000) + " sec"); |
1599 |
|
} |
1600 |
|
|
1601 |
|
public void await(CyclicBarrier barrier) { |
1781 |
|
|
1782 |
|
@SuppressWarnings("unchecked") |
1783 |
|
<T> T serialClone(T o) { |
1784 |
+ |
T clone = null; |
1785 |
|
try { |
1786 |
|
ObjectInputStream ois = new ObjectInputStream |
1787 |
|
(new ByteArrayInputStream(serialBytes(o))); |
1788 |
< |
T clone = (T) ois.readObject(); |
1784 |
< |
if (o == clone) assertImmutable(o); |
1785 |
< |
assertSame(o.getClass(), clone.getClass()); |
1786 |
< |
return clone; |
1788 |
> |
clone = (T) ois.readObject(); |
1789 |
|
} catch (Throwable fail) { |
1790 |
|
threadUnexpectedException(fail); |
1789 |
– |
return null; |
1791 |
|
} |
1792 |
+ |
if (o == clone) assertImmutable(o); |
1793 |
+ |
else assertSame(o.getClass(), clone.getClass()); |
1794 |
+ |
return clone; |
1795 |
|
} |
1796 |
|
|
1797 |
|
/** |
1810 |
|
(new ByteArrayInputStream(bos.toByteArray())); |
1811 |
|
T clone = (T) ois.readObject(); |
1812 |
|
if (o == clone) assertImmutable(o); |
1813 |
< |
assertSame(o.getClass(), clone.getClass()); |
1813 |
> |
else assertSame(o.getClass(), clone.getClass()); |
1814 |
|
return clone; |
1815 |
|
} |
1816 |
|
|