NetworkChannel.getOption(...) throws java.lang.AssertionError: Option not found

Norman Maurer norman.maurer at
Wed Aug 8 17:18:42 UTC 2018


I just wanted to double check that I am not doing something wrong here.

This code will throw an java.lang.AssertionError: Option not found :

public static void main(String[] args) throws IOException {

private static void getAllSupportedOptions(NetworkChannel channel) throws IOException {
    try {
        for (SocketOption<?> option : channel.supportedOptions()) {
    } finally {

It throws for ServerSocketChannel. The option that throws here is IP_TOS which is returned by supportedOptions().

We recently got this reported in netty where we make use of such a pattern:

If this sounds like a bug (I am very confident it is one) I can create an issue. 

This happens on latest java8, 9, 10 and 11 on MacOS. I did not test Linux yet.

As a side-note it would be nice if the AssertionError would have included the option for which it throws.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nio-dev mailing list