RFR [14] 8151678: com/sun/jndi/ldap/LdapTimeoutTest.java failed due to timeout on DeadServerNoTimeoutTest is incorrect

Martin Buchholz martinrb at google.com
Tue Sep 10 16:40:05 UTC 2019

Here's a canonical example of an "expected timeout" test that seems natural
and readable to me.
timeoutMillis() returns 12ms, adjusted by timeout factor.  Ldap might need
a bigger value.

     * timed await times out if not counted down before timeout
    public void testAwaitTimeout() throws InterruptedException {
        final CountDownLatch l = new CountDownLatch(1);
        Thread t = newStartedThread(new CheckedRunnable() {
            public void realRun() throws InterruptedException {
                assertEquals(1, l.getCount());

                long startTime = System.nanoTime();
                assertFalse(l.await(timeoutMillis(), MILLISECONDS));
                assertTrue(millisElapsedSince(startTime) >=

                assertEquals(1, l.getCount());

        assertEquals(1, l.getCount());

More information about the core-libs-dev mailing list