author | dfuchs |
Mon, 23 Apr 2018 15:45:40 +0100 | |
branch | http-client-branch |
changeset 56474 | fe2bf7b369b8 |
parent 56463 | b583caf69b39 |
child 56507 | 2294c51eae30 |
permissions | -rw-r--r-- |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
1 |
/* |
49765 | 2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
4 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
10 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
15 |
* accompanied this code). |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
16 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
20 |
* |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
23 |
* questions. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
24 |
*/ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
25 |
|
49765 | 26 |
package jdk.internal.net.http; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
27 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
28 |
import java.io.IOException; |
48083 | 29 |
import java.lang.System.Logger.Level; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
30 |
import java.net.InetSocketAddress; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
31 |
import java.net.StandardSocketOptions; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
32 |
import java.nio.ByteBuffer; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
33 |
import java.nio.channels.SelectableChannel; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
34 |
import java.nio.channels.SelectionKey; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
35 |
import java.nio.channels.SocketChannel; |
48083 | 36 |
import java.security.AccessController; |
37 |
import java.security.PrivilegedActionException; |
|
38 |
import java.security.PrivilegedExceptionAction; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
39 |
import java.util.concurrent.CompletableFuture; |
49765 | 40 |
import jdk.internal.net.http.common.FlowTube; |
41 |
import jdk.internal.net.http.common.Log; |
|
42 |
import jdk.internal.net.http.common.MinimalFuture; |
|
43 |
import jdk.internal.net.http.common.Utils; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
44 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
45 |
/** |
48083 | 46 |
* Plain raw TCP connection direct to destination. |
47 |
* The connection operates in asynchronous non-blocking mode. |
|
48 |
* All reads and writes are done non-blocking. |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
49 |
*/ |
48083 | 50 |
class PlainHttpConnection extends HttpConnection { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
51 |
|
48083 | 52 |
private final Object reading = new Object(); |
44639
5c2838d882a5
8178147: Race conditions in timeout handling code in http/2 incubator client
dfuchs
parents:
42460
diff
changeset
|
53 |
protected final SocketChannel chan; |
49765 | 54 |
private final SocketTube tube; // need SocketTube to call signalClosed(). |
48083 | 55 |
private final PlainHttpPublisher writePublisher = new PlainHttpPublisher(reading); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
56 |
private volatile boolean connected; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
57 |
private boolean closed; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
58 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
59 |
// should be volatile to provide proper synchronization(visibility) action |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
60 |
|
48083 | 61 |
final class ConnectEvent extends AsyncEvent { |
62 |
private final CompletableFuture<Void> cf; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
63 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
64 |
ConnectEvent(CompletableFuture<Void> cf) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
65 |
this.cf = cf; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
66 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
67 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
68 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
69 |
public SelectableChannel channel() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
70 |
return chan; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
71 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
72 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
73 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
74 |
public int interestOps() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
75 |
return SelectionKey.OP_CONNECT; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
76 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
77 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
78 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
79 |
public void handle() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
80 |
try { |
48083 | 81 |
assert !connected : "Already connected"; |
82 |
assert !chan.isBlocking() : "Unexpected blocking channel"; |
|
49765 | 83 |
if (debug.on()) |
84 |
debug.log("ConnectEvent: finishing connect"); |
|
48083 | 85 |
boolean finished = chan.finishConnect(); |
86 |
assert finished : "Expected channel to be connected"; |
|
49765 | 87 |
if (debug.on()) |
88 |
debug.log("ConnectEvent: connect finished: %s Local addr: %s", |
|
89 |
finished, chan.getLocalAddress()); |
|
48083 | 90 |
connected = true; |
91 |
// complete async since the event runs on the SelectorManager thread |
|
92 |
cf.completeAsync(() -> null, client().theExecutor()); |
|
93 |
} catch (Throwable e) { |
|
94 |
client().theExecutor().execute( () -> cf.completeExceptionally(e)); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
95 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
96 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
97 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
98 |
@Override |
48083 | 99 |
public void abort(IOException ioe) { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
100 |
close(); |
48083 | 101 |
client().theExecutor().execute( () -> cf.completeExceptionally(ioe)); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
102 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
103 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
104 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
105 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
106 |
public CompletableFuture<Void> connectAsync() { |
48083 | 107 |
CompletableFuture<Void> cf = new MinimalFuture<>(); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
108 |
try { |
48083 | 109 |
assert !connected : "Already connected"; |
110 |
assert !chan.isBlocking() : "Unexpected blocking channel"; |
|
111 |
boolean finished = false; |
|
49765 | 112 |
PrivilegedExceptionAction<Boolean> pa = |
113 |
() -> chan.connect(Utils.resolveAddress(address)); |
|
48083 | 114 |
try { |
115 |
finished = AccessController.doPrivileged(pa); |
|
116 |
} catch (PrivilegedActionException e) { |
|
117 |
cf.completeExceptionally(e.getCause()); |
|
118 |
} |
|
119 |
if (finished) { |
|
49765 | 120 |
if (debug.on()) debug.log("connect finished without blocking"); |
48083 | 121 |
connected = true; |
122 |
cf.complete(null); |
|
123 |
} else { |
|
49765 | 124 |
if (debug.on()) debug.log("registering connect event"); |
48083 | 125 |
client().registerEvent(new ConnectEvent(cf)); |
126 |
} |
|
127 |
} catch (Throwable throwable) { |
|
128 |
cf.completeExceptionally(throwable); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
129 |
} |
48083 | 130 |
return cf; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
131 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
132 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
133 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
134 |
SocketChannel channel() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
135 |
return chan; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
136 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
137 |
|
48083 | 138 |
@Override |
139 |
final FlowTube getConnectionFlow() { |
|
140 |
return tube; |
|
141 |
} |
|
142 |
||
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
143 |
PlainHttpConnection(InetSocketAddress addr, HttpClientImpl client) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
144 |
super(addr, client); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
145 |
try { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
146 |
this.chan = SocketChannel.open(); |
48083 | 147 |
chan.configureBlocking(false); |
56463
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
148 |
trySetReceiveBufferSize(client.getReceiveBufferSize()); |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
149 |
if (debug.on()) { |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
150 |
int bufsize = getInitialBufferSize(); |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
151 |
debug.log("Initial receive buffer size is: %d", bufsize); |
48263
a559b7cd1dea
8193370: Provide more user friendly defaults for HTTP/2 client settings
dfuchs
parents:
48083
diff
changeset
|
152 |
} |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
153 |
chan.setOption(StandardSocketOptions.TCP_NODELAY, true); |
56463
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
154 |
// wrap the channel in a Tube for async reading and writing |
48083 | 155 |
tube = new SocketTube(client(), chan, Utils::getBuffer); |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
156 |
} catch (IOException e) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
157 |
throw new InternalError(e); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
158 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
159 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
160 |
|
56463
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
161 |
private int getInitialBufferSize() { |
48263
a559b7cd1dea
8193370: Provide more user friendly defaults for HTTP/2 client settings
dfuchs
parents:
48083
diff
changeset
|
162 |
try { |
56463
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
163 |
return chan.getOption(StandardSocketOptions.SO_RCVBUF); |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
164 |
} catch(IOException x) { |
49765 | 165 |
if (debug.on()) |
56463
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
166 |
debug.log("Failed to get initial receive buffer size on %s", chan); |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
167 |
} |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
168 |
return 0; |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
169 |
} |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
170 |
|
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
171 |
private void trySetReceiveBufferSize(int bufsize) { |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
172 |
try { |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
173 |
if (bufsize > 0) { |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
174 |
chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize); |
b583caf69b39
http-client-branch: do not set receive buffer size unless explicitly requested
dfuchs
parents:
56451
diff
changeset
|
175 |
} |
48263
a559b7cd1dea
8193370: Provide more user friendly defaults for HTTP/2 client settings
dfuchs
parents:
48083
diff
changeset
|
176 |
} catch(IOException x) { |
49765 | 177 |
if (debug.on()) |
178 |
debug.log("Failed to set receive buffer size to %d on %s", |
|
179 |
bufsize, chan); |
|
48263
a559b7cd1dea
8193370: Provide more user friendly defaults for HTTP/2 client settings
dfuchs
parents:
48083
diff
changeset
|
180 |
} |
a559b7cd1dea
8193370: Provide more user friendly defaults for HTTP/2 client settings
dfuchs
parents:
48083
diff
changeset
|
181 |
} |
a559b7cd1dea
8193370: Provide more user friendly defaults for HTTP/2 client settings
dfuchs
parents:
48083
diff
changeset
|
182 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
183 |
@Override |
48083 | 184 |
HttpPublisher publisher() { return writePublisher; } |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
185 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
186 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
187 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
188 |
public String toString() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
189 |
return "PlainHttpConnection: " + super.toString(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
190 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
191 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
192 |
/** |
48083 | 193 |
* Closes this connection |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
194 |
*/ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
195 |
@Override |
49765 | 196 |
public void close() { |
197 |
synchronized (this) { |
|
198 |
if (closed) { |
|
199 |
return; |
|
200 |
} |
|
201 |
closed = true; |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
202 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
203 |
try { |
48083 | 204 |
Log.logTrace("Closing: " + toString()); |
49765 | 205 |
if (debug.on()) |
206 |
debug.log("Closing channel: " + client().debugInterestOps(chan)); |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
207 |
chan.close(); |
49765 | 208 |
tube.signalClosed(); |
209 |
} catch (IOException e) { |
|
210 |
Log.logTrace("Closing resulted in " + e); |
|
211 |
} |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
212 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
213 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
214 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
215 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
216 |
ConnectionPool.CacheKey cacheKey() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
217 |
return new ConnectionPool.CacheKey(address, null); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
218 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
219 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
220 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
221 |
synchronized boolean connected() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
222 |
return connected; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
223 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
224 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
225 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
226 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
227 |
boolean isSecure() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
228 |
return false; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
229 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
230 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
231 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
232 |
boolean isProxied() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
233 |
return false; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
234 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
235 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff
changeset
|
236 |
} |