On 07/11/2018 15:16, Chris Hegarty wrote:
Socket and ServerSocket supportedOptions() caches the supported options
in a static field on the assumption that all implementations support
the same set of options. This assumption is incorrect.

The cache can be on a per-socket basis ( which has been implemented in
the webrev ), or maybe even removed completely and just defer to the
impl. The reason I left the per-socket cache is to avoid creating the
additional unmodifiable wrapper for every access ( Argh! why didn't we
specify that SocketImpl::supportedOptions returns an unmodifiable set,
then there would be no need for this defensive wrapper )

This should to be fixed in advance of JEP 337, which will use a RDMA
SocketImpl that supports RDMA specific socket options.

http://cr.openjdk.java.net/~chegar/8213418/webrev.00/
Right, the caching, if any, has to be per instance in order to work with different SocketImpl implementations. The change drops the synchronization and so brings up the question as to whether this method is thread safe or not. One simple approach (and there are several) is to get rid of the optionsSet flag and change options to be volatile. You could use Set.copyOf too.

-Alan

Reply via email to