Fixes #2536 - Broken ClientConnectTest.testConnectionTimeout_Concurrent.

Using try-with-resources to keep the Socket instance
from being GCd before the test finishes.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2018-05-16 14:48:05 +02:00
parent 804b770581
commit 7a7aa0f1b1
1 changed files with 11 additions and 9 deletions

View File

@ -22,6 +22,7 @@ import java.net.ConnectException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.URI; import java.net.URI;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -476,8 +477,8 @@ public class ClientConnectTest
Future<Session> future = client.connect(wsocket, wsUri); Future<Session> future = client.connect(wsocket, wsUri);
// Accept the connection, but do nothing on it (no response, no upgrade, etc) // Accept the connection, but do nothing on it (no response, no upgrade, etc)
serverSocket.accept(); try (Socket socket = serverSocket.accept())
{
// The attempt to get upgrade response future should throw error // The attempt to get upgrade response future should throw error
try try
{ {
@ -489,4 +490,5 @@ public class ClientConnectTest
} }
} }
} }
}
} }