Skip to content

Commit

Permalink
ZOOKEEPER-3542: X509UtilTest#testClientRenegotiationFails is flaky on…
Browse files Browse the repository at this point in the history
… JDK8 + linux on machines with 2 cores

Author: Enrico Olivelli <[email protected]>

Reviewers: Norbert Kalmar <[email protected]>

Closes apache#1088 from eolivelli/fix/ZOOKEEPER-3542-master
  • Loading branch information
eolivelli authored and nkalmar committed Sep 18, 2019
1 parent 7b8b376 commit d6900bf
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
import java.security.Security;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import javax.net.ssl.HandshakeCompletedEvent;
Expand Down Expand Up @@ -538,6 +540,7 @@ public void testClientRenegotiationFails() throws Throwable {
SSLSocket clientSocket = null;
SSLSocket serverSocket = null;
final AtomicInteger handshakesCompleted = new AtomicInteger(0);
final CountDownLatch handshakeCompleted = new CountDownLatch(1);
try {
InetSocketAddress localServerAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), port);
listeningSocket.bind(localServerAddress);
Expand All @@ -550,6 +553,7 @@ public SSLSocket call() throws Exception {
@Override
public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) {
handshakesCompleted.getAndIncrement();
handshakeCompleted.countDown();
}
});
assertEquals(1, sslSocket.getInputStream().read());
Expand Down Expand Up @@ -582,6 +586,7 @@ public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent)
workerPool.shutdown();
// Make sure the first handshake completed and only the second
// one failed.
handshakeCompleted.await(5, TimeUnit.SECONDS);
assertEquals(1, handshakesCompleted.get());
}
}
Expand Down

0 comments on commit d6900bf

Please sign in to comment.