author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 58614 | 29624901d8bc |
child 58801 | 119ac9128c1b |
permissions | -rw-r--r-- |
2 | 1 |
/* |
54246
f04e3492fd88
8221252: (sc) SocketChannel and its socket adaptor need to handle connection reset
alanb
parents:
49001
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.nio.ch; |
|
27 |
||
48761 | 28 |
import java.io.IOException; |
29 |
import java.io.InputStream; |
|
30 |
import java.io.OutputStream; |
|
31 |
import java.net.InetAddress; |
|
32 |
import java.net.InetSocketAddress; |
|
33 |
import java.net.Socket; |
|
34 |
import java.net.SocketAddress; |
|
35 |
import java.net.SocketException; |
|
36 |
import java.net.SocketOption; |
|
37 |
import java.net.StandardSocketOptions; |
|
38 |
import java.nio.channels.SocketChannel; |
|
58614
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
39 |
import java.security.AccessController; |
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
40 |
import java.security.PrivilegedActionException; |
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
41 |
import java.security.PrivilegedExceptionAction; |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
42 |
import java.util.Set; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
43 |
|
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
44 |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
2 | 45 |
|
46 |
// Make a socket channel look like a socket. |
|
47 |
// |
|
48 |
// The methods in this class are defined in exactly the same order as in |
|
49 |
// java.net.Socket so as to simplify tracking future changes to that class. |
|
50 |
// |
|
51 |
||
48761 | 52 |
class SocketAdaptor |
2 | 53 |
extends Socket |
54 |
{ |
|
55 |
// The channel being adapted |
|
56 |
private final SocketChannelImpl sc; |
|
57 |
||
58 |
// Timeout "option" value for reads |
|
34774
03b4e6dc367b
8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents:
29224
diff
changeset
|
59 |
private volatile int timeout; |
2 | 60 |
|
11106
802bb70d8fa2
7115586: Suppress creation of SocketImpl in SocketAdaptor's constructor
chegar
parents:
9679
diff
changeset
|
61 |
private SocketAdaptor(SocketChannelImpl sc) throws SocketException { |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
62 |
super(DummySocketImpl.create()); |
2 | 63 |
this.sc = sc; |
64 |
} |
|
65 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
66 |
static Socket create(SocketChannelImpl sc) { |
58614
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
67 |
PrivilegedExceptionAction<Socket> pa = () -> new SocketAdaptor(sc); |
11106
802bb70d8fa2
7115586: Suppress creation of SocketImpl in SocketAdaptor's constructor
chegar
parents:
9679
diff
changeset
|
68 |
try { |
58614
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
69 |
return AccessController.doPrivileged(pa); |
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
70 |
} catch (PrivilegedActionException pae) { |
29624901d8bc
8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
aefimov
parents:
54620
diff
changeset
|
71 |
throw new InternalError("Should not reach here", pae); |
11106
802bb70d8fa2
7115586: Suppress creation of SocketImpl in SocketAdaptor's constructor
chegar
parents:
9679
diff
changeset
|
72 |
} |
2 | 73 |
} |
74 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
75 |
@Override |
2 | 76 |
public void connect(SocketAddress remote) throws IOException { |
77 |
connect(remote, 0); |
|
78 |
} |
|
79 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
80 |
@Override |
2 | 81 |
public void connect(SocketAddress remote, int timeout) throws IOException { |
82 |
if (remote == null) |
|
83 |
throw new IllegalArgumentException("connect: The address can't be null"); |
|
84 |
if (timeout < 0) |
|
85 |
throw new IllegalArgumentException("connect: timeout can't be negative"); |
|
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
86 |
try { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
87 |
if (timeout > 0) { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
88 |
long nanos = MILLISECONDS.toNanos(timeout); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
89 |
sc.blockingConnect(remote, nanos); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
90 |
} else { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
91 |
sc.blockingConnect(remote, Long.MAX_VALUE); |
2 | 92 |
} |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
93 |
} catch (Exception e) { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
94 |
Net.translateException(e, true); |
2 | 95 |
} |
96 |
} |
|
97 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
98 |
@Override |
2 | 99 |
public void bind(SocketAddress local) throws IOException { |
100 |
try { |
|
101 |
sc.bind(local); |
|
102 |
} catch (Exception x) { |
|
103 |
Net.translateException(x); |
|
104 |
} |
|
105 |
} |
|
106 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
107 |
@Override |
2 | 108 |
public InetAddress getInetAddress() { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48761
diff
changeset
|
109 |
InetSocketAddress remote = sc.remoteAddress(); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
110 |
if (remote == null) { |
2 | 111 |
return null; |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
112 |
} else { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48761
diff
changeset
|
113 |
return remote.getAddress(); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
114 |
} |
2 | 115 |
} |
116 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
117 |
@Override |
2 | 118 |
public InetAddress getLocalAddress() { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
119 |
if (sc.isOpen()) { |
18212
22f8c33b0690
8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents:
14342
diff
changeset
|
120 |
InetSocketAddress local = sc.localAddress(); |
22f8c33b0690
8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents:
14342
diff
changeset
|
121 |
if (local != null) { |
22f8c33b0690
8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents:
14342
diff
changeset
|
122 |
return Net.getRevealedLocalAddress(local).getAddress(); |
22f8c33b0690
8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
khazra
parents:
14342
diff
changeset
|
123 |
} |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
124 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
125 |
return new InetSocketAddress(0).getAddress(); |
2 | 126 |
} |
127 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
128 |
@Override |
2 | 129 |
public int getPort() { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48761
diff
changeset
|
130 |
InetSocketAddress remote = sc.remoteAddress(); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
131 |
if (remote == null) { |
2 | 132 |
return 0; |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
133 |
} else { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48761
diff
changeset
|
134 |
return remote.getPort(); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
135 |
} |
2 | 136 |
} |
137 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
138 |
@Override |
2 | 139 |
public int getLocalPort() { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48761
diff
changeset
|
140 |
InetSocketAddress local = sc.localAddress(); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
141 |
if (local == null) { |
2 | 142 |
return -1; |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
143 |
} else { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48761
diff
changeset
|
144 |
return local.getPort(); |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
145 |
} |
2 | 146 |
} |
147 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
148 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
149 |
public SocketAddress getRemoteSocketAddress() { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
150 |
return sc.remoteAddress(); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
151 |
} |
48761 | 152 |
|
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
153 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
154 |
public SocketAddress getLocalSocketAddress() { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
155 |
InetSocketAddress local = sc.localAddress(); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
156 |
if (local != null) { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
157 |
return Net.getRevealedLocalAddress(local); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
158 |
} else { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
159 |
return null; |
54246
f04e3492fd88
8221252: (sc) SocketChannel and its socket adaptor need to handle connection reset
alanb
parents:
49001
diff
changeset
|
160 |
} |
2 | 161 |
} |
162 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
163 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
164 |
public SocketChannel getChannel() { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
165 |
return sc; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
166 |
} |
2 | 167 |
|
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
168 |
@Override |
2 | 169 |
public InputStream getInputStream() throws IOException { |
170 |
if (!sc.isOpen()) |
|
171 |
throw new SocketException("Socket is closed"); |
|
172 |
if (!sc.isConnected()) |
|
173 |
throw new SocketException("Socket is not connected"); |
|
174 |
if (!sc.isInputOpen()) |
|
175 |
throw new SocketException("Socket input is shutdown"); |
|
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
176 |
return new InputStream() { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
177 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
178 |
public int read() throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
179 |
byte[] a = new byte[1]; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
180 |
int n = read(a, 0, 1); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
181 |
return (n > 0) ? (a[0] & 0xff) : -1; |
2 | 182 |
} |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
183 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
184 |
public int read(byte[] b, int off, int len) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
185 |
int timeout = SocketAdaptor.this.timeout; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
186 |
if (timeout > 0) { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
187 |
long nanos = MILLISECONDS.toNanos(timeout); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
188 |
return sc.blockingRead(b, off, len, nanos); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
189 |
} else { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
190 |
return sc.blockingRead(b, off, len, 0); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
191 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
192 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
193 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
194 |
public int available() throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
195 |
return sc.available(); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
196 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
197 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
198 |
public void close() throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
199 |
sc.close(); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
200 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
201 |
}; |
2 | 202 |
} |
203 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
204 |
@Override |
2 | 205 |
public OutputStream getOutputStream() throws IOException { |
206 |
if (!sc.isOpen()) |
|
207 |
throw new SocketException("Socket is closed"); |
|
208 |
if (!sc.isConnected()) |
|
209 |
throw new SocketException("Socket is not connected"); |
|
210 |
if (!sc.isOutputOpen()) |
|
211 |
throw new SocketException("Socket output is shutdown"); |
|
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
212 |
return new OutputStream() { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
213 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
214 |
public void write(int b) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
215 |
byte[] a = new byte[]{(byte) b}; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
216 |
write(a, 0, 1); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
217 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
218 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
219 |
public void write(byte[] b, int off, int len) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
220 |
sc.blockingWriteFully(b, off, len); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
221 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
222 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
223 |
public void close() throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
224 |
sc.close(); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
225 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
226 |
}; |
2 | 227 |
} |
228 |
||
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
229 |
private void setBooleanOption(SocketOption<Boolean> name, boolean value) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
230 |
throws SocketException |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
231 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
232 |
try { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
233 |
sc.setOption(name, value); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
234 |
} catch (IOException x) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
235 |
Net.translateToSocketException(x); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
236 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
237 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
238 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
239 |
private void setIntOption(SocketOption<Integer> name, int value) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
240 |
throws SocketException |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
241 |
{ |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
242 |
try { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
243 |
sc.setOption(name, value); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
244 |
} catch (IOException x) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
245 |
Net.translateToSocketException(x); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
246 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
247 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
248 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
249 |
private boolean getBooleanOption(SocketOption<Boolean> name) throws SocketException { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
250 |
try { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
251 |
return sc.getOption(name).booleanValue(); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
252 |
} catch (IOException x) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
253 |
Net.translateToSocketException(x); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
254 |
return false; // keep compiler happy |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
255 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
256 |
} |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
257 |
|
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
258 |
private int getIntOption(SocketOption<Integer> name) throws SocketException { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
259 |
try { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
260 |
return sc.getOption(name).intValue(); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
261 |
} catch (IOException x) { |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
262 |
Net.translateToSocketException(x); |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
263 |
return -1; // keep compiler happy |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
264 |
} |
2 | 265 |
} |
266 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
267 |
@Override |
2 | 268 |
public void setTcpNoDelay(boolean on) throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
269 |
setBooleanOption(StandardSocketOptions.TCP_NODELAY, on); |
2 | 270 |
} |
271 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
272 |
@Override |
2 | 273 |
public boolean getTcpNoDelay() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
274 |
return getBooleanOption(StandardSocketOptions.TCP_NODELAY); |
2 | 275 |
} |
276 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
277 |
@Override |
2 | 278 |
public void setSoLinger(boolean on, int linger) throws SocketException { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
279 |
if (!on) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
280 |
linger = -1; |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
281 |
setIntOption(StandardSocketOptions.SO_LINGER, linger); |
2 | 282 |
} |
283 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
284 |
@Override |
2 | 285 |
public int getSoLinger() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
286 |
return getIntOption(StandardSocketOptions.SO_LINGER); |
2 | 287 |
} |
288 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
289 |
@Override |
2 | 290 |
public void sendUrgentData(int data) throws IOException { |
29224
8433f5f46142
8071599: (so) Socket adapter sendUrgentData throws IllegalBlockingMode when channel configured non-blocking
bpb
parents:
25859
diff
changeset
|
291 |
int n = sc.sendOutOfBandData((byte) data); |
8433f5f46142
8071599: (so) Socket adapter sendUrgentData throws IllegalBlockingMode when channel configured non-blocking
bpb
parents:
25859
diff
changeset
|
292 |
if (n == 0) |
8433f5f46142
8071599: (so) Socket adapter sendUrgentData throws IllegalBlockingMode when channel configured non-blocking
bpb
parents:
25859
diff
changeset
|
293 |
throw new IOException("Socket buffer full"); |
2 | 294 |
} |
295 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
296 |
@Override |
2 | 297 |
public void setOOBInline(boolean on) throws SocketException { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
298 |
setBooleanOption(ExtendedSocketOption.SO_OOBINLINE, on); |
2 | 299 |
} |
300 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
301 |
@Override |
2 | 302 |
public boolean getOOBInline() throws SocketException { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
303 |
return getBooleanOption(ExtendedSocketOption.SO_OOBINLINE); |
2 | 304 |
} |
305 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
306 |
@Override |
2 | 307 |
public void setSoTimeout(int timeout) throws SocketException { |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
308 |
if (!sc.isOpen()) |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
309 |
throw new SocketException("Socket is closed"); |
2 | 310 |
if (timeout < 0) |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
311 |
throw new IllegalArgumentException("timeout < 0"); |
2 | 312 |
this.timeout = timeout; |
313 |
} |
|
314 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
315 |
@Override |
2 | 316 |
public int getSoTimeout() throws SocketException { |
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
317 |
if (!sc.isOpen()) |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
318 |
throw new SocketException("Socket is closed"); |
2 | 319 |
return timeout; |
320 |
} |
|
321 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
322 |
@Override |
2 | 323 |
public void setSendBufferSize(int size) throws SocketException { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
324 |
// size 0 valid for SocketChannel, invalid for Socket |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
325 |
if (size <= 0) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
326 |
throw new IllegalArgumentException("Invalid send size"); |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
327 |
setIntOption(StandardSocketOptions.SO_SNDBUF, size); |
2 | 328 |
} |
329 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
330 |
@Override |
2 | 331 |
public int getSendBufferSize() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
332 |
return getIntOption(StandardSocketOptions.SO_SNDBUF); |
2 | 333 |
} |
334 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
335 |
@Override |
2 | 336 |
public void setReceiveBufferSize(int size) throws SocketException { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
337 |
// size 0 valid for SocketChannel, invalid for Socket |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
338 |
if (size <= 0) |
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
339 |
throw new IllegalArgumentException("Invalid receive size"); |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
340 |
setIntOption(StandardSocketOptions.SO_RCVBUF, size); |
2 | 341 |
} |
342 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
343 |
@Override |
2 | 344 |
public int getReceiveBufferSize() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
345 |
return getIntOption(StandardSocketOptions.SO_RCVBUF); |
2 | 346 |
} |
347 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
348 |
@Override |
2 | 349 |
public void setKeepAlive(boolean on) throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
350 |
setBooleanOption(StandardSocketOptions.SO_KEEPALIVE, on); |
2 | 351 |
} |
352 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
353 |
@Override |
2 | 354 |
public boolean getKeepAlive() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
355 |
return getBooleanOption(StandardSocketOptions.SO_KEEPALIVE); |
2 | 356 |
} |
357 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
358 |
@Override |
2 | 359 |
public void setTrafficClass(int tc) throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
360 |
setIntOption(StandardSocketOptions.IP_TOS, tc); |
2 | 361 |
} |
362 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
363 |
@Override |
2 | 364 |
public int getTrafficClass() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
365 |
return getIntOption(StandardSocketOptions.IP_TOS); |
2 | 366 |
} |
367 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
368 |
@Override |
2 | 369 |
public void setReuseAddress(boolean on) throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
370 |
setBooleanOption(StandardSocketOptions.SO_REUSEADDR, on); |
2 | 371 |
} |
372 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
373 |
@Override |
2 | 374 |
public boolean getReuseAddress() throws SocketException { |
9679
d98ae8bc45fc
7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents:
7668
diff
changeset
|
375 |
return getBooleanOption(StandardSocketOptions.SO_REUSEADDR); |
2 | 376 |
} |
377 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
378 |
@Override |
2 | 379 |
public void close() throws IOException { |
5784
e565c553e9fc
6938230: (so) SocketAdaptor.close() does not translate IOException resulting in Error
alanb
parents:
5506
diff
changeset
|
380 |
sc.close(); |
2 | 381 |
} |
382 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
383 |
@Override |
2 | 384 |
public void shutdownInput() throws IOException { |
385 |
try { |
|
386 |
sc.shutdownInput(); |
|
387 |
} catch (Exception x) { |
|
388 |
Net.translateException(x); |
|
389 |
} |
|
390 |
} |
|
391 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
392 |
@Override |
2 | 393 |
public void shutdownOutput() throws IOException { |
394 |
try { |
|
395 |
sc.shutdownOutput(); |
|
396 |
} catch (Exception x) { |
|
397 |
Net.translateException(x); |
|
398 |
} |
|
399 |
} |
|
400 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
401 |
@Override |
2 | 402 |
public String toString() { |
403 |
if (sc.isConnected()) |
|
404 |
return "Socket[addr=" + getInetAddress() + |
|
405 |
",port=" + getPort() + |
|
406 |
",localport=" + getLocalPort() + "]"; |
|
407 |
return "Socket[unconnected]"; |
|
408 |
} |
|
409 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
410 |
@Override |
2 | 411 |
public boolean isConnected() { |
412 |
return sc.isConnected(); |
|
413 |
} |
|
414 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
415 |
@Override |
2 | 416 |
public boolean isBound() { |
1152
29d6145d1097
4640544: New I/O: Complete socket-channel functionality
alanb
parents:
715
diff
changeset
|
417 |
return sc.localAddress() != null; |
2 | 418 |
} |
419 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
420 |
@Override |
2 | 421 |
public boolean isClosed() { |
422 |
return !sc.isOpen(); |
|
423 |
} |
|
424 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
425 |
@Override |
2 | 426 |
public boolean isInputShutdown() { |
427 |
return !sc.isInputOpen(); |
|
428 |
} |
|
429 |
||
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
430 |
@Override |
2 | 431 |
public boolean isOutputShutdown() { |
432 |
return !sc.isOutputOpen(); |
|
433 |
} |
|
54620
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
434 |
|
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
435 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
436 |
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
437 |
sc.setOption(name, value); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
438 |
return this; |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
439 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
440 |
|
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
441 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
442 |
public <T> T getOption(SocketOption<T> name) throws IOException { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
443 |
return sc.getOption(name); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
444 |
} |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
445 |
|
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
446 |
@Override |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
447 |
public Set<SocketOption<?>> supportedOptions() { |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
448 |
return sc.supportedOptions(); |
13b67c1420b8
8222774: (ch) Replace uses of stateLock and blockingLock with j.u.c. locks
alanb
parents:
54246
diff
changeset
|
449 |
} |
2 | 450 |
} |