mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8213418: Socket/ServerSocket supportedOptions does not work with custom SocketImpl
Reviewed-by: alanb, dfuchs
This commit is contained in:
parent
7d4e8d0e26
commit
4187dff26a
3 changed files with 214 additions and 29 deletions
|
@ -993,8 +993,8 @@ class ServerSocket implements java.io.Closeable {
|
|||
return getImpl().getOption(name);
|
||||
}
|
||||
|
||||
private static Set<SocketOption<?>> options;
|
||||
private static boolean optionsSet = false;
|
||||
// cache of unmodifiable impl options. Possibly set racy, in impl we trust
|
||||
private volatile Set<SocketOption<?>> options;
|
||||
|
||||
/**
|
||||
* Returns a set of the socket options supported by this server socket.
|
||||
|
@ -1008,19 +1008,17 @@ class ServerSocket implements java.io.Closeable {
|
|||
* @since 9
|
||||
*/
|
||||
public Set<SocketOption<?>> supportedOptions() {
|
||||
synchronized (ServerSocket.class) {
|
||||
if (optionsSet) {
|
||||
return options;
|
||||
}
|
||||
try {
|
||||
SocketImpl impl = getImpl();
|
||||
options = Collections.unmodifiableSet(impl.supportedOptions());
|
||||
} catch (IOException e) {
|
||||
options = Collections.emptySet();
|
||||
}
|
||||
optionsSet = true;
|
||||
return options;
|
||||
Set<SocketOption<?>> so = options;
|
||||
if (so != null)
|
||||
return so;
|
||||
|
||||
try {
|
||||
SocketImpl impl = getImpl();
|
||||
options = Collections.unmodifiableSet(impl.supportedOptions());
|
||||
} catch (IOException e) {
|
||||
options = Collections.emptySet();
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1789,8 +1789,8 @@ class Socket implements java.io.Closeable {
|
|||
return getImpl().getOption(name);
|
||||
}
|
||||
|
||||
private static Set<SocketOption<?>> options;
|
||||
private static boolean optionsSet = false;
|
||||
// cache of unmodifiable impl options. Possibly set racy, in impl we trust
|
||||
private volatile Set<SocketOption<?>> options;
|
||||
|
||||
/**
|
||||
* Returns a set of the socket options supported by this socket.
|
||||
|
@ -1804,18 +1804,16 @@ class Socket implements java.io.Closeable {
|
|||
* @since 9
|
||||
*/
|
||||
public Set<SocketOption<?>> supportedOptions() {
|
||||
synchronized (Socket.class) {
|
||||
if (optionsSet) {
|
||||
return options;
|
||||
}
|
||||
try {
|
||||
SocketImpl impl = getImpl();
|
||||
options = Collections.unmodifiableSet(impl.supportedOptions());
|
||||
} catch (IOException e) {
|
||||
options = Collections.emptySet();
|
||||
}
|
||||
optionsSet = true;
|
||||
return options;
|
||||
Set<SocketOption<?>> so = options;
|
||||
if (so != null)
|
||||
return so;
|
||||
|
||||
try {
|
||||
SocketImpl impl = getImpl();
|
||||
options = Collections.unmodifiableSet(impl.supportedOptions());
|
||||
} catch (IOException e) {
|
||||
options = Collections.emptySet();
|
||||
}
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue