< prev index next >
test/jdk/java/net/httpclient/websocket/ConnectionHandover.java
Print this page
*** 29,46 ****
/*
* @test
* @bug 8164625
* @summary Verifies HttpClient yields the connection to the WebSocket
* @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.
*
--- 29,42 ----
/*
* @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 {
/*
* 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,68 ****
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() { });
! WebSocket ws1 = webSocketBuilder.buildAsync().join();
! try {
ws1.abort();
- } catch (IOException ignored) { }
! WebSocket ws2 = webSocketBuilder.buildAsync().join(); // Exception here if the connection was pooled
! try {
ws2.abort();
- } catch (IOException ignored) { }
}
}
}
--- 46,62 ----
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();
! WebSocket ws1 = webSocketBuilder
! .buildAsync(uri, new WebSocket.Listener() { }).join();
ws1.abort();
! WebSocket ws2 = webSocketBuilder
! .buildAsync(uri, new WebSocket.Listener() { }).join(); // Exception here if the connection was pooled
ws2.abort();
}
}
}
< prev index next >