mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8268056: Update java.net and java.nio to use switch expressions
Reviewed-by: dfuchs, michaelm, chegar, iris, alanb
This commit is contained in:
parent
9cfd560bb1
commit
438895903b
2 changed files with 30 additions and 41 deletions
|
@ -211,25 +211,17 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
|
|||
throw new SocketException("Reply from SOCKS server has bad length: " + n);
|
||||
if (data[0] != 0 && data[0] != 4)
|
||||
throw new SocketException("Reply from SOCKS server has bad version");
|
||||
SocketException ex = null;
|
||||
switch (data[1]) {
|
||||
case 90:
|
||||
// Success!
|
||||
external_address = endpoint;
|
||||
break;
|
||||
case 91:
|
||||
ex = new SocketException("SOCKS request rejected");
|
||||
break;
|
||||
case 92:
|
||||
ex = new SocketException("SOCKS server couldn't reach destination");
|
||||
break;
|
||||
case 93:
|
||||
ex = new SocketException("SOCKS authentication failed");
|
||||
break;
|
||||
default:
|
||||
ex = new SocketException("Reply from SOCKS server contains bad status");
|
||||
break;
|
||||
}
|
||||
SocketException ex = switch (data[1]) {
|
||||
case 90 -> {
|
||||
// Success!
|
||||
external_address = endpoint;
|
||||
yield null;
|
||||
}
|
||||
case 91 -> new SocketException("SOCKS request rejected");
|
||||
case 92 -> new SocketException("SOCKS server couldn't reach destination");
|
||||
case 93 -> new SocketException("SOCKS authentication failed");
|
||||
default -> new SocketException("Reply from SOCKS server contains bad status");
|
||||
};
|
||||
if (ex != null) {
|
||||
in.close();
|
||||
out.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue