src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java
branchhttp-client-branch
changeset 55992 10cefe168d6d
parent 55989 76ac25076fdc
child 56024 de352132c7e8
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java	Fri Dec 15 10:31:21 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java	Fri Dec 15 13:35:56 2017 +0300
@@ -164,11 +164,11 @@
         }
         CompletableFuture<WebSocket> cf = transport.sendBinary(message, isLast);
         // Optimize?
-        //        if (cf.isDone()) {
-        //            outstandingSend.set(false);
-        //        } else {
-        //            cf.whenComplete((r, e) -> outstandingSend.set(false));
-        //        }
+        //     if (cf.isDone()) {
+        //         outstandingSend.set(false);
+        //     } else {
+        //         cf.whenComplete((r, e) -> outstandingSend.set(false));
+        //     }
         return cf.whenComplete((r, e) -> outstandingSend.set(false));
     }
 
@@ -182,6 +182,9 @@
         return transport.sendPong(message);
     }
 
+    // TODO: this is the only method that works unconditionally: e.g. even if CF
+    // completes with an exception, the output will be closed
+    // Even if arguments are illegal the closure will happen (e.g. a default message)
     @Override
     public CompletableFuture<WebSocket> sendClose(int statusCode, String reason) {
         if (!isLegalToSendFromClient(statusCode)) {
@@ -193,15 +196,12 @@
     /*
      * Sends a Close message, then shuts down the output since no more
      * messages are expected to be sent after this.
-     *
-     * TODO: Even if arguments are illegal the default message will be sent.
      */
     private CompletableFuture<WebSocket> sendClose0(int statusCode, String reason ) {
         // TODO: MUST be a CF created once and shared across sendClose, otherwise
         // a second sendClose may prematurely close the channel
         outputClosed = true;
         return transport.sendClose(statusCode, reason)
-                .orTimeout(60, TimeUnit.SECONDS)
                 .whenComplete((r, error) -> {
                     try {
                         transport.closeOutput();