src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
38 import java.net.ProtocolException; |
38 import java.net.ProtocolException; |
39 import java.net.URI; |
39 import java.net.URI; |
40 import java.nio.ByteBuffer; |
40 import java.nio.ByteBuffer; |
41 import java.util.concurrent.CompletableFuture; |
41 import java.util.concurrent.CompletableFuture; |
42 import java.util.concurrent.CompletionStage; |
42 import java.util.concurrent.CompletionStage; |
43 import java.util.concurrent.TimeUnit; |
|
44 import java.util.concurrent.TimeoutException; |
43 import java.util.concurrent.TimeoutException; |
45 import java.util.concurrent.atomic.AtomicBoolean; |
44 import java.util.concurrent.atomic.AtomicBoolean; |
46 import java.util.concurrent.atomic.AtomicReference; |
45 import java.util.concurrent.atomic.AtomicReference; |
47 import java.util.function.Function; |
46 import java.util.function.Function; |
48 |
47 |
200 private CompletableFuture<WebSocket> sendClose0(int statusCode, String reason ) { |
199 private CompletableFuture<WebSocket> sendClose0(int statusCode, String reason ) { |
201 // TODO: MUST be a CF created once and shared across sendClose, otherwise |
200 // TODO: MUST be a CF created once and shared across sendClose, otherwise |
202 // a second sendClose may prematurely close the channel |
201 // a second sendClose may prematurely close the channel |
203 outputClosed = true; |
202 outputClosed = true; |
204 return transport.sendClose(statusCode, reason) |
203 return transport.sendClose(statusCode, reason) |
205 .whenComplete((r, error) -> { |
204 .whenComplete((result, error) -> { |
206 try { |
205 try { |
207 transport.closeOutput(); |
206 transport.closeOutput(); |
208 } catch (IOException e) { |
207 } catch (IOException e) { |
209 Log.logError(e); |
208 Log.logError(e); |
210 } |
209 } |
211 if (error instanceof TimeoutException) { |
210 Throwable cause = Utils.getCompletionCause(error); |
|
211 if (cause instanceof TimeoutException) { |
212 try { |
212 try { |
213 transport.closeInput(); |
213 transport.closeInput(); |
214 } catch (IOException e) { |
214 } catch (IOException e) { |
215 Log.logError(e); |
215 Log.logError(e); |
216 } |
216 } |