JDK-8209152 : (so) ServerSocketChannel::supportedOptions includes IP_TOS
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8u40,9,12
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-08-08
  • Updated: 2018-09-18
  • Resolved: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b10Fixed
Related Reports
Relates :  
Description
An issue with ServerSocketChannel::supportedOptions including the IP_TOS socket is reported here.
  http://mail.openjdk.java.net/pipermail/nio-dev/2018-August/005365.html

It seems that the ServerSocketChannel has had partial support for IP_TOS since JDK 8u40 as a result of JDK- 8029607. The option can be set but cannot be read. The references to IP_TOS should be removed from ServerSocketChannelImpl.

The following test, maybe test/jdk/java/nio/channels/etc/PrintSupportedOptions.java demonstrates the issue:

/**
 * @test
 * @run PrintSupportedOptions
 * @run main/othervm -Djava.net.preferIPv4Stack=true PrintSupportedOptions
 *

import java.io.IOException;
import java.net.SocketOption;
import java.nio.channels.DatagramChannel;
import java.nio.channels.NetworkChannel;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

public class PrintSupportedOptions {

    @FunctionalInterface
    interface  NetworkChannelSupplier<T extends NetworkChannel> {
        T get() throws IOException;
    }

    public static void main(String[] args) throws IOException {
        test(() -> SocketChannel.open());
        test(() -> ServerSocketChannel.open());
        test(() -> DatagramChannel.open());
    }

    static void test(NetworkChannelSupplier supplier) throws IOException {
        try (NetworkChannel ch = supplier.get()) {
            System.out.println(ch);
            for (SocketOption<?> opt : ch.supportedOptions()) {
                System.out.format("    %s -> %s%n", opt.name(), ch.getOption(opt));
            }
        }
    }
}