< prev index next >
test/jdk/java/net/httpclient/websocket/ConnectionHandover.java
Print this page
@@ -29,18 +29,14 @@
/*
* @test
* @bug 8164625
* @summary Verifies HttpClient yields the connection to the WebSocket
+ * @build DummyWebSocketServer
* @run main/othervm -Djdk.httpclient.HttpClient.log=trace ConnectionHandover
*/
public class ConnectionHandover {
-
- static {
- LoggingHelper.setupLogging();
- }
-
/*
* An I/O channel associated with the connection is closed by WebSocket.abort().
* If this connection is returned to the connection pool, then the second
* attempt to use it would fail with a ClosedChannelException.
*
@@ -50,19 +46,17 @@
public static void main(String[] args) throws IOException {
try (DummyWebSocketServer server = new DummyWebSocketServer()) {
server.open();
URI uri = server.getURI();
WebSocket.Builder webSocketBuilder =
- HttpClient.newHttpClient().newWebSocketBuilder(uri, new WebSocket.Listener() { });
+ HttpClient.newHttpClient().newWebSocketBuilder();
- WebSocket ws1 = webSocketBuilder.buildAsync().join();
- try {
+ WebSocket ws1 = webSocketBuilder
+ .buildAsync(uri, new WebSocket.Listener() { }).join();
ws1.abort();
- } catch (IOException ignored) { }
- WebSocket ws2 = webSocketBuilder.buildAsync().join(); // Exception here if the connection was pooled
- try {
+ WebSocket ws2 = webSocketBuilder
+ .buildAsync(uri, new WebSocket.Listener() { }).join(); // Exception here if the connection was pooled
ws2.abort();
- } catch (IOException ignored) { }
}
}
}
< prev index next >