Skip to content

Commit

Permalink
#10698 fix racy assertion
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Oct 13, 2023
1 parent 57dcf7c commit 937713f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -600,16 +601,17 @@ public void testHostNameVerificationFailure() throws Exception
startClient(clientTLSFactory);

CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Throwable> throwableRef = new AtomicReference<>();
client.newRequest("localhost", connector.getLocalPort())
.scheme(HttpScheme.HTTPS.asString())
.send(result ->
{
Throwable failure = result.getFailure();
if (failure instanceof SSLPeerUnverifiedException)
latch.countDown();
throwableRef.set(result.getRequestFailure());
latch.countDown();
});

assertTrue(latch.await(10, TimeUnit.SECONDS));
assertInstanceOf(SSLPeerUnverifiedException.class, throwableRef.get());
}

@Test
Expand Down

0 comments on commit 937713f

Please sign in to comment.