test: catch socketexception which may also be thrown
We need to catch SocketException as this can be thrown during the handshake we expect to fail if the server closes the socket during the handshake. Closes elastic/elasticsearch#2378 Original commit: elastic/x-pack-elasticsearch@45c4b93ab6
This commit is contained in:
parent
0aec22d0ca
commit
8d6b279bf2
|
@ -32,6 +32,7 @@ import javax.net.ssl.SSLSocketFactory;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.SocketException;
|
||||
import java.nio.file.AtomicMoveNotSupportedException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -45,6 +46,7 @@ import java.util.Map.Entry;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
/**
|
||||
* Integration tests for SSL reloading support
|
||||
|
@ -113,9 +115,10 @@ public class SSLReloadIntegTests extends ShieldIntegTestCase {
|
|||
InetSocketTransportAddress address = (InetSocketTransportAddress) internalCluster()
|
||||
.getInstance(Transport.class, node).boundAddress().publishAddress();
|
||||
try (SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(address.getAddress(), address.getPort())) {
|
||||
assertThat(socket.isConnected(), is(true));
|
||||
socket.startHandshake();
|
||||
fail("handshake should not have been successful!");
|
||||
} catch (SSLHandshakeException expected) {
|
||||
} catch (SSLHandshakeException | SocketException expected) {
|
||||
}
|
||||
|
||||
KeyStore nodeStore = KeyStore.getInstance("jks");
|
||||
|
|
Loading…
Reference in New Issue