8241988: DatagramSocket incorrectly caches the first set of socket options

Reviewed-by: msheppar, dfuchs, alanb
This commit is contained in:
Chris Hegarty 2020-04-03 07:16:35 +01:00
parent a76f0f78ad
commit 61940fe4ce
3 changed files with 242 additions and 27 deletions

View file

@ -808,24 +808,4 @@ public class MulticastSocket extends DatagramSocket {
} // synch p
} //synch ttl
} //method
private static Set<SocketOption<?>> options;
private static boolean optionsSet = false;
@Override
public Set<SocketOption<?>> supportedOptions() {
synchronized (MulticastSocket.class) {
if (optionsSet) {
return options;
}
try {
DatagramSocketImpl impl = getImpl();
options = Collections.unmodifiableSet(impl.supportedOptions());
} catch (SocketException ex) {
options = Collections.emptySet();
}
optionsSet = true;
return options;
}
}
}